Blockchain Name Service include serveral protocol's SDK to resolution BNS, such as resolver, address, multihash and more.
NodeJS is a javascript runtime build on Chrome’s V8 engine. npm is the package manager for NodeJS. Use the official installer from nodejs.org. Install the one which says "Recommended for Most Users"
Use this commands in the console:
npm install bns-sdk --save
Include the module you need. Initialize it with endpoint and specify the network ID.
const Ethereum = require("../../lib/BNS").Ethereum
const ethereum = new Ethereum({
restURL: `https://mainnet.infura.io`,
networkId: '3'
})
networkId
:1
: The endpoint is main net.3
: The endpoint is test net.
EthereumNameService allows users to resolve a domain name and get the context, address or multihash related to it. The following exapmle shows how to get resolver of a domain.
(async () => {
try {
const resolver = await ethereum.EthereumNameService.getResolver("portalnetwork.eth")
console.log(resolver);
} catch (error) {
console.error(error)
}
})()
node
: a domain name you want to look up.- Return: the resolver address of the domain.
The function allows users to look up domain's resolver address.
node
: a domain name you want to look up.- Return: the binded address of the domain.
The function allows users to look up domain's binded address.
node
: a domain name you want to look up.- Return: the binded content of the domain.
The function allows users to look up domain's binded content.
node
: a domain name you want to look up.- Return: the binded multihash of the domain.
The function allows users to look up domain's binded multihash.
See CONTRIBUTING.md for how to help out.
See LICENSE for details.