# dns.getRecords

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

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

Source: https://ensforge.com/docs/reference/sdk/dns/get-records

<ApiMeta kind="Read" stability="stable" since="1.0.0" source="packages/sdk/src/actions/dns/getRecords/index.ts#L52" batchable />

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

## When to use [#when-to-use]

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

## Details [#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 [#signature]

```ts
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](/docs/sdk/look-up-many-at-once).

## Parameters [#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](/docs/reference/sdk/client#read-options).

## Returns [#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 [#errors]

| Error | Codes | When |
| --- | --- | --- |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_NAME`](/docs/reference/errors/INVALID_NAME) | invalid names. |
| [`NetworkError`](/docs/reference/errors/network-error) | [`RPC_REQUEST_FAILED`](/docs/reference/errors/RPC_REQUEST_FAILED), [`RPC_TIMEOUT`](/docs/reference/errors/RPC_TIMEOUT), [`RATE_LIMITED`](/docs/reference/errors/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](/docs/sdk/errors-explained).

## Examples [#examples]

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Reading a TXT record set"
const dns = await ens.dns.getRecords({ name: "alice.eth", records: [{ name: "alice.eth", type: 16 }] })
```
</Tab>

<Tab>
```ts title="Reading a TXT record set with a standalone call"
import { Actions } from "@ensforge/sdk"

const dns = await Actions.dns.getRecords(publicClient, { name: "alice.eth", records: [{ name: "alice.eth", type: 16 }] })
```
</Tab>

<Tab>
```ts title="Reading a TXT record set in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

const dns = yield* Actions.dns.getRecords(ens, { name: "alice.eth", records: [{ name: "alice.eth", type: 16 }] })
```
</Tab>
</Tabs>

## Example response [#example-response]

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

```ts
await ens.dns.getRecords({ name: "ens.domains" })
```

```json
{
  "resolver": null,
  "zonehash": null,
  "records": []
}
```

## See also [#see-also]

- [`dns.setRecords`](/docs/reference/sdk/dns/set-records) to change them