EVMNS DOCS
  • Introduction
  • FAQ
    • Common FAQ
    • Registration FAQ
    • Points FAQ
  • Users Guide
    • How to add EOS EVM network into wallet?
    • How to transfer EOS tokens across EOS and EOS-EVM networks?
    • How to withdraw EOS Token from Binance to EOSEVM network
    • Access EVMNS Mobile with MetaMask Wallet
    • Guide for whitelist holders to register a domain?
  • Multi-Chain
  • Key Features
  • DAPP DEVELOPER GUIDE
    • EVMNS Enabling your DApp
    • Working with EVMNS
    • Resloving Names
    • Managing Names
  • Additional Information
    • What is DID
    • Why DID is Needed
    • Development
    • Contact & Community
Powered by GitBook
On this page
  1. DAPP DEVELOPER GUIDE

Working with EVMNS

PreviousEVMNS Enabling your DAppNextResloving Names

Last updated 1 year ago

Before you can begin interacting with EVMNS, you will need to obtain a reference to the EVMNS registry. How you do this depends on the library you are using.

Example code for the Javascript-based APIs (ethers.js) here expect that they are being run inside a DApp browser, such as Chrome with, which exposes the ethereum object.


// GetContract
const EVMRegistrarController = await ethers.getContract('EVMRegistrarController', deployer)
const publicResolver = await ethers.getContract('PublicResolver', deployer)

// PublicResolver address
var resolver = publicResolver.address
var secret = '0x0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF'
var name = '123.evm'
var owner = '0x...'
var duration = 3600 * 24 * 365

// IsAvailable
const available = await EVMRegistrarController.available(name)

if (!available) return;

// Get commitment
const commitment = await EVMRegistrarController.makeCommitment(
    name,
    owner,
    duration,
    secret,
    resolver,
    [],
    0,
    0,
  )
// Commit 
await EVMRegistrarController.commit(commitment)

// WaitSeconds 15s
// Register
var value = 5 * Math.pow(10, 18) // 5 eos
const res = await EVMRegistrarController.register(
    name,
    owner,
    duration,
    secret,
    resolver,
    [],
    false,
    0,
    { value },
  )

Currently, ethers.js support for EVMNS name resolution. In this library, you can input an EVMNS name wherever an address is required, eliminating the need for direct interaction with EVMNS APIs unless you choose to manually resolve names or perform other EVMNS operations.

metamask installed