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('wevm.eth'),
})
// '0xd2135CfB216b74109775236E36d4b433F1DF507B'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 ensAddress = await publicClient.getEnsAddress({
  name: normalize('wevm.eth'), 
})blockNumber (optional)
- Type: 
number 
The block number to perform the read against.
const ensAddress = await publicClient.getEnsAddress({
  name: normalize('wevm.eth'),
  blockNumber: 15121123n, 
})blockTag (optional)
- Type: 
'latest' | 'earliest' | 'pending' | 'safe' | 'finalized' - Default: 
'latest' 
The block tag to perform the read against.
const ensAddress = await publicClient.getEnsAddress({
  name: normalize('wevm.eth'),
  blockTag: 'safe', 
})coinType (optional)
- Type: 
number 
The ENSIP-9 coin type to fetch the address for
const ensAddress = await publicClient.getEnsAddress({
  name: normalize('wevm.eth'), 
  coinType: 60, 
})gatewayUrls (optional)
- Type: 
string[] 
A set of Universal Resolver gateways, used for resolving CCIP-Read requests made through the ENS Universal Resolver Contract.
const ensAddress = await publicClient.getEnsAddress({
  name: normalize('wevm.eth'), 
  gatewayUrls: ["https://ccip.ens.xyz"], 
})strict (optional)
- Type: 
boolean - Default: 
false 
A boolean value that when set to true will strictly propagate all ENS Universal Resolver Contract errors.
const ensAddress = await publicClient.getEnsAddress({
  name: normalize('wevm.eth'), 
  strict: true, 
})universalResolverAddress (optional)
- Type: 
Address - Default: 
client.chain.contracts.ensUniversalResolver.address 
Address of ENS Universal Resolver Contract.
const ensAddress = await publicClient.getEnsAddress({
  name: normalize('wevm.eth'),
  universalResolverAddress: '0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376', 
})Live Example
Check out the usage of getEnsAddress in the live ENS Examples below.