Try it Live
Run ENS examples in the interactive playground
ENS Usage Patterns
All examples import the module as a namespace:Parse user input
Normalize once, reject empty input, and keep the normalized value for everything downstream.Validate a form field
UseisValid() for a yes/no check, such as enabling a submit button. It accepts names that are valid but not normalized.
isValid() does not return the canonical form.
Compute a registry node
The ENS registry and resolvers key records by namehash.node as the bytes32 node argument of resolver(node), addr(node), or text(node, key). The ENS Resolution skill shows the contract calls.
Compute a labelhash
The.eth registrar uses the labelhash of the second-level label as the ERC-721 token ID.
labelhash does not split on dots. Pass one label, not a full name.
Verify the namehash recursion
namehash(label.parent) = keccak256(namehash(parent) ‖ labelhash(label)):
Reverse record node
Reverse records live under<address-hex-without-0x, lowercase>.addr.reverse.
Display a name
Hashnormalize() output. Show beautify() output.
Compare names
Compare normalized strings. Raw strings give false negatives.Narrow unknown input
is() narrows unknown to Ens when the value is a non-empty string. Normalize afterwards; is() does not validate.
Inject a keccak256 implementation
TheNamehash and Labelhash factories take keccak256 as a dependency. Use them to share one hash implementation across your app or to swap in WASM.

