17

How do you properly verify a contract on etherscan that is deployed by another contact?

I deployed a contract that deploys other contracts onto the blockchain.

The original contract is verified , however when that contract deploys contract onto the blockchain, I am unable to verify the contract.

Can anyone help with this?

0

5 Answers 5

9

It is not possible as on 24th March 2018. Etherscan is unable to locate contract code on the address of subcontract.

Here is the transaction which deploys two contracts. But for the second contract, etherscan is unable to find contract code.

The second contract does exist and this was verified by using "at address" feature of remix. Until there are some updates to etherscan, it is not possible to verify the contract created by other contract.

3
  • 1
    Feb 2019, still not possible. Commented Feb 13, 2019 at 18:43
  • Rinkeby March 4th, 2019. Still not possible Commented Mar 4, 2019 at 17:14
  • 3
    Possible by Oct 1, 2020, Anyone facing same problem please check my answer below. Commented Oct 1, 2020 at 10:37
7

I have deployed a contract from another contract: https://etherscan.io/tx/0x8fd885ce7ad7b6a591d9614d41cbb1d97aa7d2e290f6aa52531ce3d4c799a5ff

which deployed: https://etherscan.io/address/0xb1400278014f34c8243b15613a4b463b51fb6f2a#code

and I was able to verify contract using the same compiler version and optimization. You have to encode all constructor arguments yourself though, using web3.eth.abi.encodeParameters

that's how I was able to verify it on etherscan.

3
  • It seems etherscan allows you to verify contracts deployed by contracts as long as constructor parameters are not dynamic length (string, bytes, uint[]). Commented Jul 16, 2018 at 0:44
  • 1
    Based on the most upvoted answer, there might be more conditions where etherscan fails. Commented Jul 16, 2018 at 0:55
  • Can you show, how would you implement that, and after 4 years there is any new way? Commented Apr 5, 2022 at 8:18
5

If you're a Hardhat user, you can use the hardhat-etherscan plugin:

$ yarn hardhat --network NETWORK_NAME verify CONTRACT_ADDRESS --param1 --param2

It works even with contracts deployed by other contracts because it uses the standard json input format. You can read more about how this feature of the Solidity compiler in the docs.

0

Have never deployed a secondary contract, but I would imagine you could enter your "other" contract's source code into Solidity to retrieve the ABI needed for Etherscan.

From the Compile tab:

  1. Click Details
  2. Scroll down to Interface (ABI)
  3. Click on the icon Copy value to clipboard

You've stated that you've already verified the "original" contract, so I'm assuming you're okay with the rest of the steps on Etherscan.

1
  • Not sure where I would plug the ABI at etherscan.io/verifyContract The ABI it asks for are in bytecode format per the docs, the ABI that solidity browser gives is not in bytecode but rather something that looks like JSON. This is the actual contract I am trying to verify.. etherscan.io/address/… The actual inputs passed to the deployed contract as consructor arguments were the following parameters 1000000,0,MARIA CANJE,CANJE,0xfDDEdAaa4a86B0B68Fd85D77E8399D0Fe8264289 Commented Oct 8, 2017 at 14:13
-1

It's possible by Oct 01,2020 You just have to specify correct complier version, If you deployed your contract using Truffle, then your complier version by default will be the version of "solc" package used to compile your contract code.

By default "solc" package set "optizations" to "Yes"

So when you verify your contract then "Optimization" should be selected as "Yes"

Here is the sample contract and sub-contract code verified on kovan network.

Hope this helps.

Your Answer

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

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