Work with FNS

FNS Development info

Deployment

At this stage, we are deployed on Mainnet.

Contracts Deployed on Mainnet:

  • Multicall: 0x8ccEEf57F2E092562DBB969f38B68711F493b543

  • FNSRegistry: 0x916915d0d41EaA8AAEd70b2A5Fb006FFc213961b

  • ReverseRegistrar: 0xc49833d827b01e1465c65221A59885Fb71614a26

  • Registrar: 0x45d9d6408d5159a379924cf423cb7e15C00fA81f

  • FixedPriceOracle: 0x5e838eF42d5D1D8B3F691d7dbFC49D8a9f6aC577

  • RegistrarController:0xDA3c407a23Ef96930f1A07903fB8360D8926991E

  • PublicResolver: 0xed9bd04b1BB87Abe2EfF583A977514940c95699c

Github

Contracts and its deployment code, as well as the front-end and back-end implementations are all open source.

See all in FNS DAO Github.

How to use

Integrate FNS contract on Hyperspace network as an example:

Resolve name to address

// Initialize the contract instance
const ethers = require("ethers");
const hash = require("@ethersproject/hash");

const resolverAbi = [
  "function addr(bytes32 node, uint256 coinType) view returns (bytes)",
  "function name(bytes32 node) view returns (string)"
];
const publicResolverAddr = '0xe2c015abb52e22227354f78297f0c2de3807b311';
const provider = new ethers.providers.StaticJsonRpcProvider('https://hyperspace.filfox.info/rpc/v1');

const ContractPublicResolver = new ethers.Contract(
  publicResolverAddr,
  resolverAbi,
  provider,
);

// Resolve name to address
const name = 'lickey.fil';
const namehash = ethers.utils.namehash(name);
ContractPublicResolver.addr(namehash, 461).then((address) => {
  console.log(ethers.utils.toUtf8String(address));
}).catch((error)=> {
  console.log(error);
});

Reverse Resolver (Primary Name):address to name

// Reverse Resolver
const addr = '0x76346faC442F153ED8691fF88b1297643260d8a0';
const reverseNode = ethers.utils.namehash(hash.ensNormalize(`${addr.substring(2).toLocaleLowerCase()}.addr.reverse`));
console.log(reverseNode);

ContractPublicResolver.name(reverseNode).then((name) => {
    console.log(name);
  }).catch((error)=> {
    console.log(error);
  });

We will add more integration methods and demos ASAP, and finally release an SDK. Stay tuned.

Last updated