Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @rsksmart/rns-resolver with all npm packages installed. Try it out:

@rsksmart/rns-resolver lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("@rsksmart/rns-resolver/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@rsksmart/rns-resolver v2.0.0

RNS Resolver

logo

rns-resolver

RNS Resolver

CircleCI npm docs specs

npm i @rsksmart/rns-resolver

Deployments:

Features

Supported resolution protocols:

Architecture:

  • Upgradeable contracts using OpenZeppelin Upgrades OpenZeppelin Upgrades.
  • Use setAuthorisation to enable others set your records.
  • Use multicall to perform multiple operations in one call/transaction.

Usage

pragma solidity ^0.5.0;

import "@rsksmart/rns-registry/contracts/AbstractRNS.sol";
import "@rsksmart/rns-resolver/contracts/RSKAddrResolver.sol";

contract RNSTransfer {
  AbstractRNS rns;

  constructor(AbstractRNS _rns) public {
    rns = _rns;
  }

  function transfer(bytes32 node) public {
    address resolver = RSKAddrResolver(rns.resolver(node));
    address addr = resolver.addr(node);

    addr.transfer(msg.value);
  }
}
const Web3 = require('web3');
const ResolverData = require('@rsksmart/rns-resolver/ResolverData.json');

const web3 = new Web3('https://public-node.rsk.co')
const Resolver = new web3.eth.Contract(ResolverData.abi, ResolverData.address.rskMainnet);

Types

There are TypeScript typing definitions of the contracts published together with the original contracts. Supported contract's libraries are:

  • web3 version 1.* - web3-v1-contracts
  • web3 version 2.* - web3-v2-contracts
  • truffle - truffle-contracts
  • ethers - ethers-contracts

You can use them as follow:

import Web3 from 'web3'
import AddrResolver from '@rsksmart/rns-resolver/types/web3-v1-contracts/ResolverV1.d.ts'
import ResolverData from '@rsksmart/rns-resolver/ResolverData.json'

const web3 = new Web3('https://public-node.rsk.co')
const resolver = new web3.eth.Contract(ResolverData.abi, ResolverData.address.rskMainnet) as AddrResolver

Replace web3-v1-contracts with the proper library version.


Legacy contracts:

Usage

pragma solidity ^0.5.0;

import "@rsksmart/rns-registry/contracts/legacy/AbstractRNS.sol";
import "@rsksmart/rns-resolver/contracts/legacy/AbstractAddrResolver.sol";

contract RNSTransfer {
  AbstractRNS rns;

  constructor(AbstractRNS _rns) public {
    rns = _rns;
  }

  function transfer(bytes32 node) public {
    address resolver = AbstractAddrResolver(rns.resolver(node));
    address addr = resolver.addr(node);

    addr.transfer(msg.value);
  }
}
const Web3 = require('web3');
const AddrResolverData = require('@rsksmart/rns-resolver/AddrResolverData.json');

const web3 = new Web3('https://public-node.rsk.co')
const AddrResolver = new web3.eth.Contract(AddrResolverData.abi, AddrResolverData.address.rskMainnet);

Types

import Web3 from 'web3'
import AddrResolver from '@rsksmart/rns-resolver/types/web3-v1-contracts/AddrResolverData.d.ts'
import AddrResolverData from '@rsksmart/rns-resolver/AddrResolverData.json'

const web3 = new Web3('https://public-node.rsk.co')
const resolver = new web3.eth.Contract(AddrResolverData.abi, AddrResolverData.address.rskMainnet) as AddrResolver

Replace web3-v1-contracts with the proper library version.

Old deployments

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free