Skip to content

getEnsText

Gets a text record for specified ENS name.

Calls resolve(bytes, bytes) on ENS Universal Resolver Contract.

Usage

example.ts
import { normalize } from 'viem/ens'
import { publicClient } from './client'
 
const ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'),
  key: 'com.twitter',
})
// 'wagmi_sh'

Returns

string | null

The text record for ENS name.

Returns null if name does not have text assigned.

Parameters

name

  • Type: string

ENS name to get Text for.

const ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'), 
  key: 'com.twitter',
})

key

  • Type: string

ENS key to get Text for.

const ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'),
  key: 'com.twitter', 
})

blockNumber (optional)

  • Type: number

The block number to perform the read against.

const ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'),
  key: 'com.twitter',
  blockNumber: 15121123n, 
})

blockTag (optional)

  • Type: 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
  • Default: 'latest'

The block tag to perform the read against.

const ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'),
  key: 'com.twitter',
  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 ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'),
  key: 'com.twitter',
  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 ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'),
  key: 'com.twitter',
  strict: true, 
})

universalResolverAddress (optional)

  • Type: Address
  • Default: client.chain.contracts.ensUniversalResolver.address

Address of ENS Universal Resolver Contract.

const ensText = await publicClient.getEnsText({
  name: normalize('wevm.eth'),
  key: 'com.twitter',
  universalResolverAddress: '0x74E20Bd2A1fE0cdbe45b9A1d89cb7e0a45b36376', 
})