@justaname.id/hybrid-primary-name
Version:
> **This package is no longer maintained.** It will not receive updates, > bug fixes, or security patches. The repository has been archived. > Please do not use this package in new projects.
29 lines (28 loc) • 1.15 kB
TypeScript
import { ClientWithEns } from "@ensdomains/ensjs/dist/types/contracts/consts";
import { Address } from "viem";
/**
* Creates a plugin that extends the PublicClient with ENS resolution capabilities.
* This plugin adds the ability to perform reverse ENS lookups using both on-chain
* and API-based resolution methods.
*
* @returns A function that extends the client with the getEnsFromAddress method
*/
export declare function primaryName(): (client: ClientWithEns) => {
/**
* Performs reverse ENS resolution for a given Ethereum address.
* First attempts on-chain resolution, then falls back to API-based lookup.
*
* @param address - The Ethereum address to resolve
* @returns The primary ENS name associated with the address, or null if none found
* @throws Error if the current chain ID is not supported (must be mainnet or sepolia)
*
* @example
* ```typescript
* const ensName = await client.getEnsFromAddress('0x123...')
* if (ensName) {
* console.log(`ENS name: ${ensName}`)
* }
* ```
*/
getEnsFromAddress(address: Address): Promise<string | null>;
};