record.getText
Reads one text record of an ENS name, such as url, avatar or com.twitter. Parameters, return value, errors and examples for record.getText in @ensforge/sdk.
Reads one text record of an ENS name, such as url, avatar or com.twitter.
When to use
Use to read a single profile field. Use record.get to read several records in one call.
Details
- Resolves through the Universal Resolver, so ENSv1, ENSv2, wildcard and off-chain (CCIP-Read) names all work.
- Returns
nullwhen the record, the resolver, or the resolver's text support is missing, unlessstrictis set. - Calls made in the same tick are batched into one multicall where possible.
Signature
function getText(client: Like, options: getText.Options): Promise<getText.ReturnType>Call it as ens.record.getText(options) on a client, or Actions.record.getText(client, options).
record.getText.request(options) builds a deferred read for Actions.batch. See Look up many at once.
In React, use useText.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
name (required) | string | ENS name to read. Normalized automatically. | |
key (required) | string | Text record key, e.g. url, avatar, com.twitter. |
Also takes the read options.
Returns
Resolves to string | null. The record value, or null when it is not set.
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME | the name cannot be normalized. |
NotFoundError | RECORD_NOT_FOUND, RESOLVER_NOT_FOUND | with strict. |
UnsupportedError | RESOLVER_PROFILE_UNSUPPORTED | with strict when the resolver supports none of the records. |
GatewayError | GATEWAY_REQUEST_FAILED, GATEWAY_RESPONSE_INVALID, OFFCHAIN_LOOKUP_INVALID | an off-chain gateway fails. |
DnsError | a DNS name's DNSSEC proof does not verify. | |
NetworkError | RPC_REQUEST_FAILED, RPC_TIMEOUT, RATE_LIMITED | the RPC request fails. |
It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).
See How errors work.
Examples
const url = await ens.record.getText({ name: "nick.eth", key: "url" })Example response
Recorded from Ethereum mainnet on 2026-11-18 at block 26443964. Values change as the chain does.
await ens.record.getText({ name: "vitalik.eth", key: "url" })"https://vitalik.ca"See also
record.setto write text records
Was this page helpful?