name.getNamespace
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.
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
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
kind: "l2"names the namespace family, its parent name, the L2'schainIdand the registry there that holds the name (nullwhen the L2 could not be reached).kind: "offchain"names the provider whose gateway serves the name, ornullwhen ensforge does not know it. No gateway is contacted.- Returns
nullfor 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.
Gotchas
- The location says where the name would live, not that it is registered there:
unclaimed.base.ethis on Base too.
Signature
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.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
name (required) | string | ENS name to locate. Normalized automatically. |
Also takes the read options.
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
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME | the name is invalid or the root. |
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 namespace = await ens.name.getNamespace({ name: "jesse.base.eth" })
if (namespace?.kind === "l2") console.log(namespace.id, namespace.chainId) // "basenames" 8453See also
name.getfor the name's full state
Was this page helpful?