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.
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 (
1for A,16for 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
| Option | Type | Default | Description |
|---|---|---|---|
name (required) | string | ENS name. Normalized automatically. | |
records | readonly { 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).
| Field | Type | Description |
|---|---|---|
resolver | Address | null | |
zonehash | Hex | null | |
records | readonly { readonly name: string; readonly type: number; readonly data: Hex | null; }[] |
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME | invalid names. |
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 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
dns.setRecordsto change them
Was this page helpful?