domain-web3-test
v1.0.6
Published
domain web3 test
Downloads
3
Readme
domain-test
domain域名管理SDK
- [√] 根据地址查询绑定的domain名称
- [√] 根据domain名称和指定的链反向解析出地址
- [√] 根据domain名称反向解析出不同链的地址信息
Installation
SDK安装{.tabset}
npm
npm install -S domain-test
yarn
yarn add domain-test
Exports
default - KID
getKidName
getKidResolver
Example
1.根据地址查询绑定的domain名称
const KID = require('domain-test')
const Web3 = require('web3')
let provider
let kid
provider = new Web3(new Web3.providers.HttpProvider('https://goerli.infura.io/v3/xxxxx'))
kid = new KID({ provider, networkId: 5 })
kid.getKidName('0x0000000000000000000000000000000000000000').then((res) => {
console.log('该地址绑定的kid为:', res)
}).catch((err) => {
console.log('获取kid失败:', err)
})
2.根据domain名称和指定的链反向解析出地址
const KID = require('domain-test')
const Web3 = require('web3')
let provider
let kid
provider = new Web3(new Web3.providers.HttpProvider('https://goerli.infura.io/v3/xxxxx'))
kid = new KID({ provider, networkId: 5 })
kid.getKidResolver('hello','ETH').then((res) => {
console.log('该kid解析后地址为:', res)
}).catch((err) => {
console.log('反向解析失败:', err)
})
3.根据domain名称反向解析出不同链的地址信息
const KID = require('domain-test')
const Web3 = require('web3')
let provider
let kid
provider = new Web3(new Web3.providers.HttpProvider('https://goerli.infura.io/v3/xxxxx'))
kid = new KID({ provider, networkId: 5 })
kid.getKidResolver('hello').then((res) => {
console.log('该kid解析后地址类型集合为:', res.keys)
console.log('该kid解析后地址结果集合为:', res.values)
}).catch((err) => {
console.log('反向解析失败:', err)
})