Connect to CORE ID using ethers.js

Core id is compatible with ens, you can use ethers.js to connect to CORE ID

import { ethers } from "ethers";  

const network = {
  name: "CORE",
  chainId: 1116,
  ensAddress: "0x00000000003dB7663112d1e121c6D2bb8220F671"
};  

//const provider = new ethers.providers.JsonRpcProvider("https://rpc.coredao.org/", network)
const provider = new ethers.providers.Web3Provider(window.ethereum, network)  

await provider.getBalance("coreid.core");
// { BigNumber: "26959293642897667667" }

await provider.resolveName("coreid.core");
// '0x9826a59Aa17C36e88AA2F6dC367772381f034401'  

await provider.lookupAddress("0x9826a59Aa17C36e88AA2F6dC367772381f034401");
// 'coreid.core'
// Requires primary name to be set

For more information on how to use it, you can check out the ethers.js docs

Last updated