Content Hash Resolver
The content hash resolver is based on the ENS implementation (ENSIP-7 (opens in a new tab)). It introduces the field contenthash
which allows a wide range of protocols to be supported by HNS names.
Specification
- Resolvers supporting this field MUST return
true
when thesupportsInterface
function is called with argument0xbc1c58d1
. - The value returned by
contenthash
MUST be represented as a machine-readable multicodec. The format is specified as follows:<protoCode uvarint><value []byte>
- ProtoCodes and their meanings are specified in the
multiformats/multicodec
repository. - The encoding of the value depends on the content type specified by the
protoCode
.
Examples
IPFS
Input data:
- Storage system: IPFS (0xe3)
- CID version: 1 (0x01)
- Content type: dag-pb (0x70)
- Hash function: sha2-256 (0x12)
- Hash length: 32 bytes (0x20)
- Hash: 0x29f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f
Binary format:
0xe3010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f
Text format:
ipfs://QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4
Swarm
Input data:
- Storage system: Swarm (0xe4)
- CID version: 1 (0x01)
- Content type: swarm-manifest (0xfa)
- Hash function: keccak256 (0x1b)
- Hash length: 32 bytes (0x20)
- Hash: 0xd1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162
Binary format:
0xe40101fa011b20d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162
Text format:
bzz://d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162
Example usage with swarm hash:
$ swarm hash ens contenthash d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162
> e40101fa011b20d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162