GithubHelp home page GithubHelp logo

rns-js's Introduction

rns-js

npm version CircleCI

RNS JavaScript library.

npm i web3 @rsksmart/rns

Types are exposed under '@rsksmart/rns/types'

Or just use it directly in your webpage:

<script src="https://unpkg.com/[email protected]/dist/web3.min.js"></script>
<script src="https://unpkg.com/@rsksmart/[email protected]/lib/rns.min.js"></script>

Don't forget to specify the desired version of the package!

Basic usage

Instance de library:

import Web3 from 'web3'
import RNS from '@rsksmart/rns'
import { ChainId } from '@rsksmart/rns/types'

const web3 = new Web3('https://public-node.rsk.co')
const rns = new RNS(web3)

Get an address:

rns.addr('testing.rsk').then(console.log)

Get Bitcoin address:

rns.addr('testing.rsk', ChainId.BITCOIN).then(console.log)

Check if testing.rsk domain is available:

rns.available('testing.rsk').then(console.log)

Check if example.testing.rsk subdomain is available:

rns.subdomains.available('testing.rsk', 'example').then(console.log)

Reverse lookup: get name of a given address:

rns.reverse('0x0000000000000000000000000000000123456789').then(console.log)

Check out more operations details in the RSK Developers Portal.

Advanced usage

Use Web3 Contract directly

async function myCustomGetOwner(domain) {
  const web3 = new Web3('https://public-node.rsk.co')
  const rns = new RNS(web3)

  await rns.compose()

  const owner = await rns.contracts.registry.methods.owner(domain).call()

  return owner;
}

Resource record implementations

Coins supported:

  • BTC (base58check P2PKH and P2SH, and bech32 segwit)
  • LTC (base58check P2PHK and P2SH, and bech32 segwit)
  • DOGE (base58check P2PKH and P2SH)
  • MONA (base58check P2PKH and P2SH, and bech32 segwit)
  • DASH (base58check P2PKH and P2SH)
  • ETH (checksummed-hex)
  • ETC (checksummed-hex)
  • RSK (checksummed-hex)
  • XDAI (checksummed-hex)
  • XRP (base58check-ripple)
  • BCH (base58check and cashAddr; decodes to cashAddr)
  • BNB (bech32)
  • XLM (ed25519 public key)
  • ATOM (bech32)
  • TRX (base58check)
  • NEM (base32)
  • EOS
  • KSM (ss58)

Content types supported:

  • ipfs
  • bzz
  • onion
  • onion3

Run for development

Install dependencies:

git clone [email protected]:rnsdomains/rns-js.git
cd rns-js
npm i

Run tests:

npm test

Try out your development, create a testing project:

# in rns-js folder
npm run build
npm link
cd ..
mkdir rns-js-test
cd rns-js-test
npm init
npm i web3
npm link @rsksmart/rns

Versioning

  • master branch point to latest release.
  • develop branch contains changes that will apply next release. The first commit after release bumps to next version.
  • Other branches (feature branches) point to develop.

Find releases scopes in milestones

rns-js's People

Contributors

dependabot[bot] avatar ilanolkies avatar javiesses avatar jessgusclark avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.