Skip to content
function resolveAddress(ctx, value): Promise<`0x${string}` | undefined>;

Attempts to resolve an Ethereum address from a string. If the provided string is already a valid Ethereum address, or if it is an ENS name, the underlying Address will be returned. If the value is not an ENS name, is not normalizable under ENSIP-15, or does not have an associated Address, the method returns undefined — these are all domain outcomes, not failures.

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 getEnsAddress call throw a ProviderConnectionError (wrapping the original error as cause) instead of being folded into undefined — an infra failure is not the same domain outcome as “this name has no address,” and callers (e.g. TanStack Query retry/cache policies) need to tell the two apart.

Parameters

ParameterTypeDescription
ctxSDKContextThe SDK context.
valuestringThe string to try and resolve to an Address.

Returns

Promise<`0x${string}` | undefined>

Address if the value is an ENS name that has an associated address, undefined if the value does not resolve to one.

Throws

ProviderConnectionError if the underlying ENS RPC call fails.