getEnsAddress 
Gets address for ENS name.
Calls resolve(bytes, bytes) on ENS Universal Resolver Contract to resolve the ENS name to address.
Usage 
import { normalize } from 'viem/ens'
import { publicClient } from './client'
 
const ensAddress = await publicClient.getEnsAddress({
  name: normalize('wagmi-dev.eth'),
})
// '0xd2135CfB216b74109775236E36d4b433F1DF507B'import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
export const publicClient = createPublicClient({
  chain: mainnet,
  transport: 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 getEnsAddress. You can use the built-in normalize function for this.
Returns 
The address that resolves to provided ENS name.
Returns null if ENS name does not resolve to address.
Parameters 
name 
- Type: 
string 
Name to get the address for.
const ensName = await publicClient.getEnsAddress({
  name: normalize('wagmi-dev.eth'), 
})blockNumber (optional) 
- Type: 
number 
The block number to perform the read against.
const ensName = await publicClient.getEnsAddress({
  name: normalize('wagmi-dev.eth'),
  blockNumber: 15121123n, 
})blockTag (optional) 
- Type: 
'latest' | 'earliest' | 'pending' | 'safe' | 'finalized' - Default: 
'latest' 
The block tag to perform the read against.
const ensName = await publicClient.getEnsAddress({
  name: normalize('wagmi-dev.eth'),
  blockTag: 'safe', 
})coinType (optional) 
- Type: 
number 
The ENSIP-9 coin type to fetch the address for
const ensName = await publicClient.getEnsAddress({
  name: normalize('wagmi-dev.eth'), 
  coinType: 60, 
})universalResolverAddress (optional) 
- Type: 
Address - Default: 
client.chain.contracts.ensUniversalResolver.address 
Address of ENS Universal Resolver Contract.
const ensName = await publicClient.getEnsAddress({
  name: normalize('wagmi-dev.eth'),
  universalResolverAddress: '0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376', 
})Live Example 
Check out the usage of getEnsAddress in the live ENS Examples below.