ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.98k stars 1.86k forks source link

Add `Rootstock` Name service `RNS` #4786

Open ahsan-javaiid opened 4 months ago

ahsan-javaiid commented 4 months ago

Description

This PR adds RNS support to ether.js. Users will be able to resolve .rsk names on Rootstock network to easily find and locate addresses using ethers.js similiar to ens.

RNS service: https://manager.rns.rifos.org/

Note: RNS is a name service similiar to ens on Rootstock network. https://dev.rootstock.io/rif/rns/

About Rootstock

Website: https://rootstock.io/ Defillama: https://defillama.com/chain/Rootstock Explorer: https://explorer.rootstock.io/ Developer portal: https://dev.rootstock.io/

Motivation

Lot of wallets, web3 tools and defi projects are using ethers.js provider instance methods resolveName and lookupAddress to resolve ens names. Adding RNS support in ethers.js will automatically enable rns feature in lot of these defi projects.

Testing Script

The resolveName and lookupAddress on provider class will resolve .rsk names and addresses. Attached is the demo script.

Build the branch in this pr: npm run build-dist Now run the below script in same directory.


const { ethers } = require("./dist/ethers.umd.js");

async function main() {

  const ROOTSTOCK_RPC_NODE = "https://public-node.rsk.co";

  const provider = new ethers.JsonRpcProvider(ROOTSTOCK_RPC_NODE);

  // rns name lookup
  const resolvedAddress = await provider.resolveName('alepc.rsk');

  console.log('resolved address: ', resolvedAddress);

  // lookup address
  const resolvedName = await provider.lookupAddress('0xA78C937844b27bEc024F042DCbE5B85d2B7344F6');

  console.log('resolved name:', resolvedName);
}

main();

Feel free to review the pr and let us know if any changes are required.

ahsan-javaiid commented 4 months ago

cc @ricmoo for review on this PR. Feel free to let me know if any changes are required. Super excited to land this PR into ethers.js 🚀

ahsan-javaiid commented 3 months ago

cc: @ricmoo Reminder for review on this PR.

mehedihassan0 commented 2 months ago

looks good

ahsan-javaiid commented 1 week ago

cc: @ricmoo Reminder for review on this PR. 🙏