Try it Live
Run ENS examples in the interactive playground
ENSIP Standards
The Ens module implements two ENS Improvement Proposals:ENSIP-1: Namehash
ENSIP-1 (originally EIP-137) defines how a name maps to a 32-byte registry node:namehash splits on . and processes labels right to left. Each label is UTF-8 encoded before hashing.
Deviations to know
ENSIP-1 requires names to be normalized before hashing. The hash functions here do not normalize or validate:- Case is hashed as given.
namehash("VITALIK.eth")differs fromnamehash("vitalik.eth"). - Empty labels are skipped.
namehash("a..eth")equalsnamehash("a.eth"), andnamehash(".eth")andnamehash("eth.")equalnamehash("eth").normalize()rejects all three inputs. labelhashhashes its whole input.labelhash("vitalik.eth")is the keccak256 of the 11-byte string, not a namehash.
normalize() first. See Encoding for the full API.
ENSIP-15: Normalization
ENSIP-15 defines a single canonical form for every valid name and rejects names that can be visually confused. The module delegates to@adraffy/ens-normalize, the reference implementation by the author of ENSIP-15:
ENSIP-15 rules you will see in practice:
The exact normalization tables are those shipped with the installed
@adraffy/ens-normalize version (^1.11.1 in package.json).
Not implemented
namehash works for any name, including reverse names: namehash("addr.reverse") returns 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2.
See Also
- ENS Overview
- Encoding - namehash and labelhash API
- Normalization - normalize and beautify API
- Security
- ENS Resolution skill

