Skip to content

Latest commit

 

History

History
1191 lines (858 loc) · 29 KB

web3-eth-ens.rst

File metadata and controls

1191 lines (858 loc) · 29 KB

web3.eth.ens

The web3.eth.ens functions let you interacting with ENS. We recommend reading the documentation ENS is providing to get deeper insights about the internals of the name service.


registryAddress

The registryAddress property can be used to define a custom registry address when you are connected to an unknown chain.

Note

If no address is defined will it try to detect the registry on the chain you are currently connected with and on the call of setProvider in the Eth module will it keep the defined address and use it for the ENS module.

Returns

String - The address of the custom registry.

Example


registry

Returns the network specific ENS registry.

Returns

Registry - The current ENS registry.

  • contract: Contract - The Registry contract with the interface we know from the Contract <eth-contract> object.
  • owner(name, callback): Promise - Deprecated please use getOwner
  • getOwner(name, callback): Promise
  • setOwner(name, address, txConfig, callback): PromiEvent
  • resolver(name, callback): Promise - Deprecated please use getResolver
  • getResolver(name, callback): Promise
  • setResolver(name, address, txConfig, callback): PromiEvent
  • getTTL(name, callback): Promise
  • setTTL(name, ttl, txConfig, callback): PromiEvent
  • setSubnodeOwner(name, label, address, txConfig, callback): PromiEvent
  • setRecord(name, owner, resolver, ttl, txConfig, callback): PromiEvent
  • setSubnodeRecord(name, label, owner, resolver, ttl, txConfig, callback): PromiEvent
  • setApprovalForAll(operator, approved, txConfig, callback): PromiEvent
  • isApprovedForAll(owner, operator, callback): Promise
  • recordExists(name, callback): Promise

Example


resolver

Returns the resolver contract to an Ethereum address.

Note

This method is deprecated please use getResolver

Parameters

  1. name - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<Resolver> - The ENS resolver for this name.

Example


getResolver

Returns the resolver contract to an Ethereum address.

Parameters

  1. name - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<Resolver> - The ENS resolver for this name.

Example


setResolver

Does set the resolver contract address of a name.

Parameters

  1. name - String: The ENS name.
  2. address - String: The contract address of the deployed Resolver contract.
  3. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  4. callback - Function: (optional) Optional callback

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example


getOwner

Returns the owner of a name.

Parameters

  1. name - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<String>` - The address of the registrar (EOA or CA).

Example


setOwner

Does set the owner of the given name.

Parameters

  1. name - String: The ENS name.
  2. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  3. callback - Function: (optional) Optional callback

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example


getTTL

Returns the caching TTL (time-to-live) of a name.

Parameters

  1. name - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<Number>

Example


setTTL

Does set the caching TTL (time-to-live) of a name.

Parameters

  1. name - String: The ENS name.
  2. ttl - Number: The TTL value (uint64)
  3. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  4. callback - Function: (optional) Optional callback

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example


setSubnodeOwner

Creates a new subdomain of the given node, assigning ownership of it to the specified owner

Parameters

  1. name - String: The ENS name.
  2. label - String: The name of the sub-domain or the sha3 hash of it
  3. address - String: The registrar of this sub-domain
  4. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  5. callback - Function: (optional) Optional callback

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example


setRecord

Sets the owner, resolver, and TTL for an ENS record in a single operation.

Parameters

  1. name - String: The ENS name.
  2. owner - String: The owner of the name record
  3. resolver - String: The resolver address of the name record
  4. ttl - String | Number: Time to live value (uint64)
  5. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  6. callback - Function: (optional) Optional callback

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example


setSubnodeRecord

Sets the owner, resolver and TTL for a subdomain, creating it if necessary.

Parameters

  1. name - String: The ENS name.
  2. label - String: The name of the sub-domain or the sha3 hash of it
  3. owner - String: The owner of the name record
  4. resolver - String: The resolver address of the name record
  5. ttl - String | Number: Time to live value (uint64)
  6. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  7. callback - Function: (optional) Optional callback

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example


setApprovalForAll

Sets or clears an approval. Approved accounts can execute all ENS registry operations on behalf of the caller.

Parameters

  1. operator - String: The operator address
  2. approved - Boolean
  3. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  4. callback - Function: (optional) Optional callback

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example


isApprovedForAll

Returns true if the operator is approved to make ENS registry operations on behalf of the owner.

Parameters

  1. owner - String: The owner address.
  2. operator - String: The operator address.
  3. callback - Function: (optional) Optional callback

Returns

Promise<Boolean>

Example


recordExists

Returns true if node exists in this ENS registry. This will return false for records that are in the legacy ENS registry but have not yet been migrated to the new one.

Parameters

  1. name - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<Boolean>

Example


getAddress

Resolves an ENS name to an Ethereum address.

Parameters

  1. ENSName - String: The ENS name to resolve.
  2. callback - Function: (optional) Optional callback

Returns

String - The Ethereum address of the given name.

Example


setAddress

Sets the address of an ENS name in his resolver.

Parameters

  1. ENSName - String: The ENS name.
  2. address - String: The address to set.
  3. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  4. callback - Function: (optional) Optional callback

Emits an AddrChanged event.

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example

For further information on the handling of contract events please see here <contract-events>.


getPubkey

Returns the X and Y coordinates of the curve point for the public key.

Parameters

  1. ENSName - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<Object<String, String>> - The X and Y coordinates.

Example


setPubkey

Sets the SECP256k1 public key associated with an ENS node

Parameters

  1. ENSName - String: The ENS name.
  2. x - String: The X coordinate of the public key.
  3. y - String: The Y coordinate of the public key.
  4. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  5. callback - Function: (optional) Optional callback

Emits an PubkeyChanged event.

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example

For further information on the handling of contract events please see here <contract-events>.


getContent

Returns the content hash associated with an ENS node.

Parameters

  1. ENSName - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<String> - The content hash associated with an ENS node.

Example


setContent

Sets the content hash associated with an ENS node.

Parameters

  1. ENSName - String: The ENS name.
  2. hash - String: The content hash to set.
  3. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  4. callback - Function: (optional) Optional callback

Emits an ContentChanged event.

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example

For further information on the handling of contract events please see here <contract-events>.


getMultihash

Returns the multihash associated with an ENS node.

Parameters

  1. ENSName - String: The ENS name.
  2. callback - Function: (optional) Optional callback

Returns

Promise<String> - The associated multihash.

Example


supportsInterface

Returns true if the related Resolver does support the given signature or interfaceId.

Parameters

  1. name - String: The ENS name.
  2. interfaceId - String: The signature of the function or the interfaceId as described in the ENS documentation
  3. callback - Function: (optional) Optional callback

Returns

Promise<Boolean>

Example


setMultihash

Sets the multihash associated with an ENS node.

Parameters

  1. ENSName - String: The ENS name.
  2. hash - String: The multihash to set.
  3. txConfig - Object: (optional) The transaction options as described ::ref::here <eth-sendtransaction>
  4. callback - Function: (optional) Optional callback

Emits an MultihashChangedevent.

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example

For further information on the handling of contract events please see here <contract-events>.


ENS events

The ENS API provides the possibility for listening to all ENS related events.

------------Known resolver events ------------

  1. AddrChanged(node bytes32, a address)
  2. ContentChanged(node bytes32, hash bytes32)
  3. NameChanged(node bytes32, name string)
  4. ABIChanged(node bytes32, contentType uint256)
  5. PubkeyChanged(node bytes32, x bytes32, y bytes32)

Returns

PromiEvent<TransactionReceipt | TransactionRevertInstructionError>

Example

------------Known registry events ------------

  1. Transfer(node bytes32, owner address)
  2. NewOwner(node bytes32, label bytes32, owner address)
  3. NewResolver(node bytes32, resolver address)
  4. NewTTL(node bytes32, ttl uint64)

Example

For further information on the handling of contract events please see here <contract-events>.