Xinfin (XDC) Network & Upgradable

Hi,
I'm building a contract for a client who wishes to deploy it to the XinFin / XDC network and requires an upgradeable contract. I'm developing with Hardhat and I have successfully deployed to both the testnet and mainnet for the XDC network.

  const TheToken = await ethers.getContractFactory("TheToken");
  const theToken = await upgrades.deployProxy(TheToken);
  await theToken.deployed();
  console.log("TheToken contract address:", theToken.address);

XDC has an explorer and I would like to verify the contract on there to formalise it. Unfortunately, when I attempt this, the explorer returns a non-descriptive error. I don't get this error if my contract is not upgradeable.

Can anyone please help with suggestions on how I can move forward?

Thank you.

Hi, welcome to the community! :wave:

Sorry, I am not familiar with this network Xinfin(XDC) network, and I am not sure whether the hardhat support it or not, you can have a try npx hardhat verify, if it does not works, maybe you can flatten all contracts into a single file to verify on the explorer manually.

Please check out the detail guide on the How to verify you contract https://www.xdc.dev/ivan_blocksscan/how-to-verify-xrc20-smart-contracts-on-blocksscan-4dgf

2 Likes

Note that to verify the source code for an upgradeable contract, use the implementation address.

You can get the implementation address from the proxy using console.log(await upgrades.erc1967.getImplementationAddress(proxyAddress));

See How to verify a contract on Etherscan/BscScan/PolygonScan for more info (details are for Etherscan but the concepts should still be relevant).