API ReferenceAdvanced utilities and typesFunction
getEnsName()
function getEnsName(ctx, params): Promise<string | null>;Reverse-resolves an Ethereum address to its primary ENS name, if any.
ENS resolution uses a mainnet-pinned client when ctx.deps.mainnetRpcUrl is configured (see
AnvilDependencies.mainnetRpcUrl), since ENS is a mainnet-only protocol; otherwise it falls back to
ctx.deps.publicClient, which is only correct when the protocol chain IS mainnet.
Transport/RPC errors from the underlying getEnsName call throw a ProviderConnectionError
(wrapping the original error as cause), mirroring resolveAddress — null is reserved for the
genuine “no primary name set” domain outcome, so infrastructure failures are never mistaken for (and
cached as) a missing name.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | SDKContext | The SDK context. |
params | GetEnsNameParams | The ENS reverse-resolution parameters. |
Returns
Promise<string | null>
The primary ENS name, or null if none is set.
Throws
ProviderConnectionError if the underlying ENS RPC call fails.