gleeth/ens

ENS (Ethereum Name Service) resolution.

Resolves human-readable .eth names to Ethereum addresses by querying the ENS registry and resolver contracts on-chain.

Examples

let assert Ok(address) = ens.resolve(provider, "vitalik.eth")
// address = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"

Values

pub fn namehash(name: String) -> BitArray

Compute the ENS namehash for a domain name.

The namehash algorithm recursively hashes labels: namehash("") = 0x00...00 namehash("eth") = keccak256(namehash("") + keccak256("eth")) namehash("vitalik.eth") = keccak256(namehash("eth") + keccak256("vitalik"))

Examples

let hash = ens.namehash("vitalik.eth")
pub const registry_address: String

ENS Registry address (same on mainnet, Goerli, Sepolia).

pub fn resolve(
  provider: provider.Provider,
  name: String,
) -> Result(String, types.GleethError)

Resolve an ENS name to an Ethereum address.

Queries the ENS registry for the resolver, then queries the resolver for the address. Returns an error if the name has no resolver or no address set.

Examples

let assert Ok(addr) = ens.resolve(provider, "vitalik.eth")
Search Document