getEnsResolver
Action for fetching ENS resolver for name.
Import
ts
import { getEnsResolver } from '@wagmi/core'
import { getEnsResolver } from '@wagmi/core'
Usage
ts
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = getEnsResolver(config, {
name: normalize('wevm.eth'),
})
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = getEnsResolver(config, {
name: normalize('wevm.eth'),
})
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
WARNING
Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsResolver
. You can use Viem's built-in normalize
function for this.
Parameters
ts
import { type GetEnsResolverParameters } from '@wagmi/core'
import { type GetEnsResolverParameters } from '@wagmi/core'
blockNumber
bigint | undefined
Block number to get resolver at.
ts
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = getEnsResolver(config, {
blockNumber: 17829139n,
name: normalize('wevm.eth'),
})
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = getEnsResolver(config, {
blockNumber: 17829139n,
name: normalize('wevm.eth'),
})
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
blockTag
'latest' | 'earliest' | 'pending' | 'safe' | 'finalized' | undefined
Block tag to get resolver at.
ts
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = getEnsResolver(config, {
blockTag: 'latest',
name: normalize('wevm.eth'),
})
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = getEnsResolver(config, {
blockTag: 'latest',
name: normalize('wevm.eth'),
})
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
chainId
config['chains'][number]['id'] | undefined
ID of chain to use when fetching data.
ts
import { getEnsResolver } from '@wagmi/core'
import { mainnet } from '@wagmi/core/chains'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = await getEnsResolver(config, {
chainId: mainnet.id,
name: normalize('wevm.eth'),
})
import { getEnsResolver } from '@wagmi/core'
import { mainnet } from '@wagmi/core/chains'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = await getEnsResolver(config, {
chainId: mainnet.id,
name: normalize('wevm.eth'),
})
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
name
string
Name to get the resolver for.
ts
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = await getEnsResolver(config, {
name: normalize('wevm.eth'),
})
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = await getEnsResolver(config, {
name: normalize('wevm.eth'),
})
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
universalResolverAddress
Address | undefined
- Address of ENS Universal Resolver Contract.
- Defaults to current chain's Universal Resolver Contract address.
ts
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = await getEnsResolver(config, {
name: normalize('wevm.eth'),
universalResolverAddress: '0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376',
})
import { getEnsResolver } from '@wagmi/core'
import { normalize } from 'viem/ens'
import { config } from './config'
const ensResolver = await getEnsResolver(config, {
name: normalize('wevm.eth'),
universalResolverAddress: '0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376',
})
ts
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
import { http, createConfig } from '@wagmi/core'
import { mainnet, sepolia } from '@wagmi/core/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})
Return Type
ts
import { type GetEnsResolverReturnType } from '@wagmi/core'
import { type GetEnsResolverReturnType } from '@wagmi/core'
Address
The address of the resolver.
Error
ts
import { type getEnsResolverError } from '@wagmi/core'
import { type getEnsResolverError } from '@wagmi/core'
TanStack Query
ts
import {
type GetEnsResolverData,
type GetEnsResolverOptions,
type GetEnsResolverQueryFnData,
type GetEnsResolverQueryKey,
getEnsResolverQueryKey,
getEnsResolverQueryOptions,
} from '@wagmi/core/query'
import {
type GetEnsResolverData,
type GetEnsResolverOptions,
type GetEnsResolverQueryFnData,
type GetEnsResolverQueryKey,
getEnsResolverQueryKey,
getEnsResolverQueryOptions,
} from '@wagmi/core/query'