Class that handles TLD registration on Ethereum network. Registration is done in 4 steps:

  1. Calling requestApproval to get registration approval.
  2. Calling sendCommitment to create commitment for registration.
  3. Waiting for 1 minute.
  4. Calling register to finish registration.

Note: After approval is receieved, domain will be reserved for 30 minutes. Since process may fail on one of following steps, it is recommended to save result of each step to be able to continue in case of failure.

Example

import { registration } from '@decentraweb/core';
const registrar = new registration.EthereumTLDRegistrar({
network: network,
provider: provider,
signer: signer
});
const approval = await registrar.requestApproval({ name: 'wallet', duration: registration.DURATION.ONE_YEAR });
const commitment = await registrar.sendCommitment(approval);
await commitment.tx.wait(1);
// Wait for 1 minute
const tx = await registrar.register(commitment);
await tx.wait(1);

Hierarchy

  • BaseRegistrar
    • EthereumTLDRegistrar

Constructors

Properties

DecentraWeb API wrapper instance

chainId: number
contract: Contract
contractConfig: ContractConfig
dwebToken: Contract

DWEB token contract

network: Network

Current network name

provider: BaseProvider
signer: Signer

Ethers.js Ethereum signer for writing data to the blockchain

wethToken?: Contract

WETH token contract, only available on the Polygon network

Accessors

Methods

  • Approve unlimited token usage by the registrar contract, so no further approvals are needed

    Parameters

    • token: "DWEB" | "WETH"

      token name. WETH is only supported on the Polygon network

    Returns Promise<TransactionReceipt>

  • Returns the price of registration in wei

    Parameters

    • entry: TLDEntry

      domain name and duration

    • isFeesInDweb: boolean = false

      if true, registration fee will be paid in DWEB tokens, otherwise in ETH

    Returns Promise<BigNumber>

    • amount in wei
  • Returns the price of registration in wei for multiple domains

    Parameters

    • requests: TLDEntry[]

      array of domain names and durations

    • isFeesInDweb: boolean

      if true, registration fee will be paid in DWEB tokens, otherwise in ETH

    Returns Promise<BigNumber>

    • total amount in wei
  • Get DWEB/WETH token amount that can be used by the registrar contract

    Parameters

    • token: "DWEB" | "WETH"

      token name. WETH is only supported on the Polygon network

    Returns Promise<BigNumber>

  • Get DWEB/WETH token balance of the signer

    Parameters

    • token: "DWEB" | "WETH"

      token name. WETH is only supported on the Polygon network

    Returns Promise<BigNumber>

  • Step 3. Finish TLD registration. This step can be called only 1 minute after sendCommitment step was completed. Also, it will throw an error if signer balance is not enough to pay for registration. Registration considered successful after 1st confirmation received.

    Parameters

    • request: CommittedRegistration

      data returned from sendCommitment step

    • isFeesInDweb: boolean = false

      if true, fees will be paid in DWEB tokens, otherwise in ETH

    Returns Promise<TransactionResponse>

    • Transaction response for registration
  • Step 1. Normalizes domain names, calls the API to check if they are available and returns approval for registration. Approved request is valid for 30 minutes.

    Parameters

    • request: TLDEntry | TLDEntry[]

      one or more domain names and durations

    • Optional owner: string

      ETH address of the owner of created TLDs

    Returns Promise<ApprovedRegistration>

    • ApprovedRegistration object that can be used to commit and register
  • Step 2. Creates a commitment for registration. Commitment is valid after 1 minute.

    Parameters

    • request: ApprovedRegistration

      data returned from requestApproval step

    Returns Promise<CommittedRegistration>

    • object that can be used to register TLD
  • Approve the DWEB/WETH token amount that can be used by the registrar contract

    Parameters

    • token: "DWEB" | "WETH"

      token name. WETH is only supported on the Polygon network

    • amount: BigNumber

      amount in wei

    Returns Promise<TransactionReceipt>

Generated using TypeDoc