Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeSDK

record.getContentHash

Reads the content hash of an ENS name (ENSIP-7), decoded into its protocol, value and URI. Options, result, errors and examples for record.getContentHash.

ReadBatchablestable
Since v1.0.0View source

Reads the content hash of an ENS name (ENSIP-7), decoded into its protocol, value and URI.

When to use

Use to find the website or content a name points to, such as an IPFS site.

Details

  • Supports ipfs, ipns, bzz (Swarm), onion, onion3, sia (Skynet) and ar (Arweave).
  • Turn the URI into an HTTP URL through the client's gateways with ContentHash.toGatewayUrl(uri, ens.config.gateways).
  • Returns null when the record is not set or cannot be decoded, unless strict is set.

Signature

function getContentHash(
  client: Like,
  options: getContentHash.Options,
): Promise<getContentHash.ReturnType>

Call it as ens.record.getContentHash(options) on a client, or Actions.record.getContentHash(client, options).

record.getContentHash.request(options) builds a deferred read for Actions.batch. See Look up many at once.

Parameters

OptionTypeDefaultDescription
name (required)stringENS name to read. Normalized automatically.

Also takes the read options.

Returns

Resolves to Decoded | null. The decoded content hash, or null when not set.

FieldTypeDescription
protocolProtocol
valuestringThe identifier without scheme, e.g. a CID.
uristringprotocol://value.

Errors

ErrorCodesWhen
InvalidInputErrorINVALID_NAMEthe name cannot be normalized.
NotFoundErrorRECORD_NOT_FOUND, RESOLVER_NOT_FOUNDwith strict.
UnsupportedErrorRESOLVER_PROFILE_UNSUPPORTEDwith strict when the resolver supports none of the records.
GatewayErrorGATEWAY_REQUEST_FAILED, GATEWAY_RESPONSE_INVALID, OFFCHAIN_LOOKUP_INVALIDan off-chain gateway fails.
DnsErrora DNS name's DNSSEC proof does not verify.
NetworkErrorRPC_REQUEST_FAILED, RPC_TIMEOUT, RATE_LIMITEDthe RPC request fails.

It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).

See How errors work.

Examples

Reading a website
const site = await ens.record.getContentHash({ name: "vitalik.eth" })
site?.uri // "ipfs://…"

Example response

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

await ens.record.getContentHash({ name: "ens.eth" })
{
  "protocol": "bzz",
  "value": "f5909b5286d9279a1f6a23d5155ddd72bb0f28f56b6b82c32de54a6529e6b1b0",
  "uri": "bzz://f5909b5286d9279a1f6a23d5155ddd72bb0f28f56b6b82c32de54a6529e6b1b0"
}

See also

Was this page helpful?