@rsksmart/rns-resolver
v2.0.0
Published
RNS Resolver
Downloads
125
Readme
npm i @rsksmart/rns-resolver
Deployments:
- RSK Mainnet: 0xD87f8121D44F3717d4bAdC50b24E50044f86D64B
- RSK Testnet: 0x25C289ccCFFf700c6a38722F4913924fE504De0e
Features
Supported resolution protocols:
- Contract addresses - EIP-137
- Multicoin addresses - EIP-2304
- Contenthash - EIP-1577
- Contract ABI - EIP-205
- SECP256k1 public keys - EIP-619
- Text records - EIP-634
- Interface discovery - EIP-1844
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
Public Resolver
- Docs
- RSK Mainnet: 0x4efd25e3d348f8f25a14fb7655fba6f72edfe93a
- RSK Testnet: 0x1e7ae43e3503efb886104ace36051ea72b301cdf
Multi Chain Resolver
- Docs
- RSK Mainnet: 0x99a12be4C89CbF6CFD11d1F2c029904a7B644368
- RSK Testnet: 0x404308f2a2eec2cdc3cb53d7d295af11c903414e