getEnsName
Gets primary name for specified address.
Calls reverse(bytes)
on ENS Universal Resolver Contract to "reverse resolve" the address to the primary ENS name.
Usage
example.ts
import { publicClient } from './client'
const ensName = await publicClient.getEnsName({
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
})
// 'wevm.eth'
Returns
string
The primary ENS name for the address.
Returns null
if address does not have primary name assigned.
Parameters
address
- Type:
Address
Address to get primary ENS name for.
const ensName = await publicClient.getEnsName({
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
})
blockNumber (optional)
- Type:
number
The block number to perform the read against.
const ensName = await publicClient.getEnsName({
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
blockNumber: 15121123n,
})
blockTag (optional)
- Type:
'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
- Default:
'latest'
The block tag to perform the read against.
const ensName = await publicClient.getEnsName({
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
blockTag: 'safe',
})
gatewayUrls (optional)
- Type:
string[]
A set of Universal Resolver gateways, used for resolving CCIP-Read requests made through the ENS Universal Resolver Contract.
const ensName = await publicClient.getEnsName({
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
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 ensName = await publicClient.getEnsName({
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
strict: true,
})
universalResolverAddress (optional)
- Type:
Address
- Default:
client.chain.contracts.ensUniversalResolver.address
Address of ENS Universal Resolver Contract.
const ensName = await publicClient.getEnsName({
address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
universalResolverAddress: '0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376',
})
Live Example
Check out the usage of getEnsName
in the live ENS Examples below.