# name.getNamespace

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

Finds where a name lives outside ENS's registries: the L2 namespace that holds it (Basenames, Linea Names, Celonames, Durin, Namespace) or the off-chain.

Source: https://ensforge.com/docs/reference/sdk/name/get-namespace

<ApiMeta kind="Read" stability="stable" since="1.1.0" source="packages/sdk/src/actions/name/getNamespace/index.ts#L64" batchable />

Finds where a name lives outside ENS's registries: the L2 namespace that holds it (Basenames,
Linea Names, Celonames, Durin, Namespace) or the off-chain provider that serves it.

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

Use to know which chain to read a name from or send its record writes to, without reading its
full state. `name.get` returns the same location as `namespace`.

## Details [#details]

- `kind: "l2"` names the namespace family, its parent name, the L2's `chainId` and the registry
  there that holds the name (`null` when the L2 could not be reached).
- `kind: "offchain"` names the provider whose gateway serves the name, or `null` when ensforge
  does not know it. No gateway is contacted.
- Returns `null` for names in ENS, and for names nothing serves.
- The L2 namespaces come from the client's deployment profile (`Deployments.Profile.namespaces`).
  Durin and Namespace names cost a read on Ethereum and one on their L2.
- A client remembers a name's location for a minute, and forgets it after its own writes.

<Callout type="warn" title="Gotchas">
- The location says where the name would live, not that it is registered there:
  `unclaimed.base.eth` is on Base too.
</Callout>

## Signature [#signature]

```ts
function getNamespace(
  client: Like,
  options: getNamespace.Options,
): Promise<getNamespace.ReturnType>
```

Call it as `ens.name.getNamespace(options)` on a client, or `Actions.name.getNamespace(client, options)`.

`name.getNamespace.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 to locate. Normalized automatically. |

Also takes the [read options](/docs/reference/sdk/client#read-options).

## Returns [#returns]

Resolves to `NameNamespace | null`. Where the name lives, or `null` for names in ENS.

| Field | Type | Description |
| --- | --- | --- |
| `kind` | `"l2"` |  |
| `parent` | `string` | The parent name the namespace hangs off, e.g. `base.eth`. |

## Errors [#errors]

| Error | Codes | When |
| --- | --- | --- |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_NAME`](/docs/reference/errors/INVALID_NAME) | the name is invalid or the root. |
| [`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="Finding the chain of a Basename"
const namespace = await ens.name.getNamespace({ name: "jesse.base.eth" })
if (namespace?.kind === "l2") console.log(namespace.id, namespace.chainId) // "basenames" 8453
```
</Tab>

<Tab>
```ts title="Finding with a bare viem client"
import { Actions } from "@ensforge/sdk"

const namespace = await Actions.name.getNamespace(publicClient, { name: "jesse.base.eth" })
```
</Tab>

<Tab>
```ts title="Finding in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

const namespace = yield* Actions.name.getNamespace(ens, { name: "jesse.base.eth" })
```
</Tab>
</Tabs>

## See also [#see-also]

- [`name.get`](/docs/reference/sdk/name/get) for the name's full state