Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeSDK

dns.getRecords

Reads DNS records and the zonehash a name stores on its resolver. Parameters, return value, errors and examples for dns.getRecords in @ensforge/sdk.

ReadBatchablestable
Since v1.0.0View source

Reads DNS records and the zonehash a name stores on its resolver.

When to use

Use to read DNS data hosted in ENS for any name, not only imported DNS names.

Details

  • Each query reads one record set by owner name and type (1 for A, 16 for TXT, …), as DNS wire-format resource records.
  • Missing records, and resolvers without DNS records, read as null.

Signature

function getRecords(
  client: Like,
  options: getRecords.Options,
): Promise<getRecords.ReturnType>

Call it as ens.dns.getRecords(options) on a client, or Actions.dns.getRecords(client, options).

dns.getRecords.request(options) builds a deferred read for Actions.batch. See Look up many at once.

Parameters

OptionTypeDefaultDescription
name (required)stringENS name. Normalized automatically.
recordsreadonly { readonly name: string; readonly type: number }[]Record sets to read, by DNS owner name and record type.

Also takes the read options.

Returns

Resolves to getRecords.ReturnType. The resolver, its zonehash and each queried record set (null when missing).

FieldTypeDescription
resolverAddress | null
zonehashHex | null
recordsreadonly { readonly name: string; readonly type: number; readonly data: Hex | null; }[]

Errors

It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).

See How errors work.

Examples

Reading a TXT record set
const dns = await ens.dns.getRecords({ name: "alice.eth", records: [{ name: "alice.eth", type: 16 }] })

Example response

Recorded from Ethereum mainnet on 2026-11-18 at block 26443964. Values change as the chain does.

await ens.dns.getRecords({ name: "ens.domains" })
{
  "resolver": null,
  "zonehash": null,
  "records": []
}

See also

Was this page helpful?