ensdomains / ensjs-v2

Javascript bindings for the Ethereum Name Service
208 stars 122 forks source link

Chainid56 #97

Closed denaliiceberg closed 2 years ago

denaliiceberg commented 2 years ago

test

// bnb domain example
const SID = require('@siddomains/sidjs').default
const SIDfunctions = require('@siddomains/sidjs')                                                                                                                                                            
const Web3 = require('web3')

let sid

async function main(name) {
  const infura = "https://bsc-mainnet.nodereal.io/v1/d0c3ef1cdb0247f4b6fae228aa76c8b8"
  const provider = new Web3.providers.HttpProvider(infura)
  sid = new SID({ provider, sidAddress: SIDfunctions.getSidAddress('56') })

  const address = await sid.name(name).getAddress() // 0x123                                                                                
  console.log("address of ${name} is ${address}", name, address)
}
main("bnb.bnb")
main("000.bnb")
main("999.bnb")
main("abc.bnb")
main("nft.bnb")
main("defi.bnb")
main("love.bnb")
main("wallet.bnb")
main("crypto.bnb")
main("satoshi.bnb")

result

➜  sidjs git:(master) ✗ node test.js 
address of ${name} is ${address} bnb.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} 000.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} nft.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} 999.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} wallet.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} satoshi.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} love.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} abc.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} crypto.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E
address of ${name} is ${address} defi.bnb 0x7E6D0E2dea2C76b8307Ff89813525241cdc3De1E