What is eth-ens-namehash?
The eth-ens-namehash package is a JavaScript library for generating ENS (Ethereum Name Service) namehashes. It provides utility functions to convert human-readable ENS names into a format that can be used in smart contracts and other Ethereum-based applications.
What are eth-ens-namehash's main functionalities?
Namehash Generation
This feature allows you to generate a namehash for a given ENS name. The namehash is a unique identifier for ENS names that can be used in smart contracts.
const namehash = require('eth-ens-namehash');
const hash = namehash.hash('example.eth');
console.log(hash);
Normalization
This feature normalizes ENS names to ensure they are in a standard format. This is useful for ensuring consistency and avoiding issues with different representations of the same name.
const namehash = require('eth-ens-namehash');
const normalized = namehash.normalize('example.eth');
console.log(normalized);
Other packages similar to eth-ens-namehash
ethjs-ens
ethjs-ens is a library for interacting with the Ethereum Name Service (ENS). It provides functions for resolving ENS names to Ethereum addresses and vice versa. Unlike eth-ens-namehash, which focuses on namehash generation, ethjs-ens offers a broader range of ENS-related functionalities.
Eth ENS Namehash
A javascript library for generating Ethereum Name Service (ENS) namehashes per spec.
Available on NPM
Installation
npm install eth-ens-namehash -S
Usage
var namehash = require('eth-ens-namehash')
var hash = namehash.hash('foo.eth')
var input = getUserInput()
var normalized = namehash.normalize(input)
Security Warning
ENS Supports UTF-8 characters, and so many duplicate names are possible. For example:
The first one has non-ascii chars. (control+F on this page and search for facebook, only the second one will match).
namehash.normalize() doesn't automagically remap those, and so other precautions should be taken to avoid user phishing.
Development
This module supports advanced JavaScript syntax, but exports an ES5-compatible module. To re-build the exported module after making changes, run npm run bundle
(must have browserify installed).