Time to read: 1 min
RIF Name Service (RNS) Javascript SDK
The @rsksmart/rns-sdk package helps you interact with the Rootstock Name Service (RNS). It lets you:
- Register .rsk domains
- Check domain and subdomain availability
- Query and set domain ownership
- Resolve domains to addresses
- Manage subdomains
- Work with partner registrars
Installation
Install the package using npm:
npm install @rsksmart/rns-sdk ethers
Contract Addresses
You will need these addresses to initialize the SDK:
| Contract | Mainnet | Rootstock Testnet |
|---|---|---|
| RNS Registry | 0xcb868aeabd31e2b66f74e9a55cf064abb31a4ad5 | 0x7d284aaac6e925aad802a53c0c69efe3764597b8 |
| RIF Token | 0x2acc95758f8b5f583470ba265eb685a8f45fc9d5 | 0x19f64674d8a5b4e652319f5e239efd3bc969a1fe |
| RSK Owner | 0x45d3e4fb311982a06ba52359d44cb4f5980e0ef1 | 0xca0a477e19bac7e0e172ccfd2e3c28a7200bdb71 |
| FIFS Addr Registrar | 0xd9c79ced86ecf49f5e4a973594634c83197c35ab | 0x90734bd6bf96250a7b262e2bc34284b0d47c1e8d |
| Partner Registrar | - | 0x8104d97f6d82a7d3afbf45f72118fad51f190c42 |
Initialization
After obtaining the contract addresses from the table above, initialize the SDK by creating instances of the desired classes, passing the relevant addresses as constructor parameters. You'll also need a signer (e.g., from ethers.js) connected to the Rootstock network.
For example, to initialize the RNS class for mainnet:
import { ethers } from 'ethers';
import { RNS } from '@rsksmart/rns-sdk';
const provider = new ethers.providers.JsonRpcProvider('https://public-node.rsk.co');
const signer = new ethers.Wallet('your-private-key', provider);
const registryAddress = '0xcb868aeabd31e2b66f74e9a55cf064abb31a4ad5' // RNS Registry Mainnet address
const rns = new RNS(registryAddress, signer);
See the individual class sections below for more details on constructors and required addresses.
SDK Classes
The SDK provides five main classes:
| Class | Purpose |
|---|---|
RNS | Domain management (owner, resolver, subdomains) |
AddrResolver | Address resolution |
RSKRegistrar | Standard .rsk domain registration |
PartnerRegistrar | Partner-based domain registration |
PartnerConfiguration | Partner contract configuration |
1. RNS Class
The RNS class handles domain management operations.
Constructor
import { Signer } from 'ethers'
import { RNS } from '@rsksmart/rns-sdk'
let signer: Signer
const rns = new RNS(registryAddress, signer)