Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

@rsksmart/rns-resolver

1.0.3 • Public • Published

rns-resolver

npm version

RNS Resolver

Install

npm i @rsksmart/rns-resolver

Usage

pragma solidity ^0.5.0;
 
import "@rsksmart/rns-resolver/contracts/AbstractRNS.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

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/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.


Keywords

Install

npm i @rsksmart/rns-resolver

DownloadsWeekly Downloads

53

Version

1.0.3

License

ISC

Unpacked Size

104 kB

Total Files

24

Last publish

Collaborators

  • avatar