RNS JS Library - Getting Started

Installation

npm i web3 @rsksmart/rns

Basic usage

import Web3 from 'web3'
import RNS from '@rsksmart/rns'

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

Find instructions in the advanced usage section if running local or custom blockchains.

Get an address:

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

Get Bitcoin address:

rns.addr('testing.rsk', '0x80000000').then(console.log)

Check if example.testing.rsk subdomain is available:

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

Reverse lookup: Get the name of a given address:

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

Create a subdomain under my parent domain:

const newOwnerAddress = '0x0000000000000000000000000000000000000001';
rns.subdomains.setOwner('mydomain.rsk', 'example', newOwnerAddress);

Check out the operations specification for more details.

Advanced usage

If you want to interact directly with the contracts, find instructions in the the advanced usage section.