1

I've created a contract factory smart contract and deployed + verified on Ropsten.

How can I verify the child-contracts on etherscan?

Parent contract: https://ropsten.etherscan.io/address/0xa3b82dc5b961405ba45d1a2f7f35ebe40b1d7ecc

Child contract: https://ropsten.etherscan.io/address/0x95BbFBA0E67Bc56dd9979Bd5BB069EB971FDFe63#code

  1. I've attempted to use the hardhat-etherscan plugin to auto-verify:

npx hardhat verify --network ropsten 0x95BbFBA0E67Bc56dd9979Bd5BB069EB971FDFe63 "Satoshiris" "SATUSI"

  1. I've attempted to manually verify by using hardhat flatten command to then input that into the UI on etherscan.

npx hardhat flatten > flattened.sol

Any help is appreciated.

2
  • Does this ethereum.stackexchange.com/a/109636 work for you?
    – Ismael
    Jul 19, 2022 at 14:01
  • In case it doesn't work can you provide more details? like solc version, source code, deploy scripts and parameters.
    – Ismael
    Jul 19, 2022 at 14:17

2 Answers 2

0
+50

The right syntax for verifying a contract that has more than one parameter in hardhat is by using --contructor-args flag. Please check doc for reference. https://hardhat.org/hardhat-runner/plugins/nomiclabs-hardhat-etherscan#complex-arguments

If the intention is to get a green tick and the source code of the contract to be displayed on all new instance of the child contract on etherscan, you can do the following.

Firstly, deploy only the child contract with some dummy arguments and verify it.

You can deploy only the child contract by adding the child contract name in hardhat's getContractFactory function. (Or if you are using remix, you can select it under the dropdown.)

  const child = await hre.ethers.getContractFactory("NFTToken");

Once it's deployed verify the deployed child contract.

npx hardhat verify --network ropsten 0x95BbFBA0E67Bc56dd9979Bd5BB069EB971FDFe63 --constructor-args arguments.js

Next, you can deploy and verify the Factory contract.

Now, whenever a new instance of a child contract is created you can see the message 'Similar Match Source Code' on etherscan and you can see the contract source code, since the contract with the same byte code is already verified!. You can see green tick and source code but, this doens't mean that the contract is verified.

1
  • Hello is there any way to automate this process? Like every time a contract is deployed by the factory I would need to manually verify the contract? This is not scalable, I am wondering what is the automated process. Jan 12 at 20:30
0

Have you provided the encoded constructor args when trying to verify the contract created by the factory? You can use https://abi.hashex.org/ to easily encode them. Otherwise could you please link to the contract source code so I can investigate other methods, thanks!

1
  • I have provided the encoded constructor args when trying to verify: npx hardhat verify --network ropsten 0x95BbFBA0E67Bc56dd9979Bd5BB069EB971FDFe63 encodedArg1 encodedArg2 It still fails to compile. Here is the contract source code: ethfiddle.com/1YHaiq_UIl Thanks in advance for looking at this.
    – Zedkay22
    Jul 17, 2022 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.