RNS JS Library - Getting Started

Installation

npm i web3 @rsksmart/rns

Or just use it directly in your webpage:

<script src="https://unpkg.com/web3@1.2.6/dist/web3.min.js"></script>
<script src="https://unpkg.com/@rsksmart/rns@1.5.11/lib/rns.min.js"></script>

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

Basic usage

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)

Remember that if you are running the code in a webpage, no import statements are needed, just instantiate the libs made available in the global scope.

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', ChainId.BITCOIN).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.

Receive updates

Get the latest updates from the Rootstock ecosystem

Loading...