0.0.13 β€’ Published 5 years ago

bns-sdk v0.0.13

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Blockchain Name Service SDK

πŸ“– Introduction

Blockchain Name Service include serveral protocol's SDK to resolution BNS, such as resolver, address, multihash and more.

πŸ” Requirement

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"

πŸ’‘ Get Start

Use this commands in the console:

npm install bns-sdk --save

πŸ“ Usage

Ethereum Name Service

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.

Class: EthereumNameService

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)
  }
})()

EthereumNameService.getResolver(node)

  • 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.

EthereumNameService.getAddress(node)

  • 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.

EthereumNameService.getContent(node)

  • 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.

EthereumNameService.getMultihash(node)

  • 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.

πŸ“£ Contributing

See CONTRIBUTING.md for how to help out.

πŸ—’ Licence

See LICENSE for details.