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.
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) andar(Arweave). - Turn the URI into an HTTP URL through the client's gateways with
ContentHash.toGatewayUrl(uri, ens.config.gateways). - Returns
nullwhen the record is not set or cannot be decoded, unlessstrictis 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
| Option | Type | Default | Description |
|---|---|---|---|
name (required) | string | ENS name to read. Normalized automatically. |
Also takes the read options.
Returns
Resolves to Decoded | null. The decoded content hash, or null when not set.
| Field | Type | Description |
|---|---|---|
protocol | Protocol | |
value | string | The identifier without scheme, e.g. a CID. |
uri | string | protocol://value. |
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME | the name cannot be normalized. |
NotFoundError | RECORD_NOT_FOUND, RESOLVER_NOT_FOUND | with strict. |
UnsupportedError | RESOLVER_PROFILE_UNSUPPORTED | with strict when the resolver supports none of the records. |
GatewayError | GATEWAY_REQUEST_FAILED, GATEWAY_RESPONSE_INVALID, OFFCHAIN_LOOKUP_INVALID | an off-chain gateway fails. |
DnsError | a DNS name's DNSSEC proof does not verify. | |
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 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
record.getto read several records
Was this page helpful?