Working with FNS

Before you can begin interacting with FNS, you will need to obtain a reference to the FNS registry. How you do this depends on the library you are using.

Example code for the Javascript-based APIs (web3.js and ethers.js) here expect that they are being run inside a DApp browser, such as Chrome with metamask installed, which exposes the ethereum object.

const Web3 = require("web3")
const ethEnabled = async () => {
  if (window.ethereum) {
    await window.ethereum.request({method: 'eth_requestAccounts'});
    window.web3 = new Web3(window.ethereum);
    return true;
  }
  return false;
}
const CONTRACT_ADDRESS = '0x57e8782c2f77B99823EeA48aCE3Eb7635F0B35F9';
const fns = new web3.eth.Contract([...], CONTRACT_ADDRESS);

Last updated