name.getLabel
Recovers a label from its labelhash through the ENSv2 LabelStore. Parameters, return value, errors and examples for name.getLabel in @ensforge/sdk.
Recovers a label from its labelhash through the ENSv2 LabelStore.
When to use
Use to display names that arrive as hashes, such as [af2c…].eth from events or indexers.
Details
- ENSv2 registries store every label they register, so this covers every ENSv2 name.
- Returns
nullwhen the LabelStore has never seen the label.
Signature
function getLabel(client: Like, options: getLabel.Options): Promise<getLabel.ReturnType>Call it as ens.name.getLabel(options) on a client, or Actions.name.getLabel(client, options).
name.getLabel.request(options) builds a deferred read for Actions.batch. See Look up many at once.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
labelhash (required) | Hex | Keccak-256 hash of the label, as from Name.labelhash. |
Also takes the read options.
Returns
Resolves to string | null. The label, or null when unknown.
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_RECORD_VALUE | labelhash is not 32 bytes. |
UnsupportedError | UNSUPPORTED_ON_DEPLOYMENT | without an ENSv2 deployment. |
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 label = await ens.name.getLabel({ labelhash: "0x5d5727cb0fb76e4944eafb88ec9a3cf0b3c9025a4b2f947729137c5d7f84f68f" })Example response
Recorded from Ethereum mainnet on 2026-11-18 at block 26443964. Values change as the chain does.
await ens.name.getLabel({ labelhash: "0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc" })"vitalik"Was this page helpful?