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?

Ayushya
  • 1,698
  • 9
  • 24
Dino Anastos
  • 847
  • 1
  • 13
  • 22

5 Answers5

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.

Ayushya
  • 1,698
  • 9
  • 24
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.

rstormsf
  • 4,337
  • 2
  • 25
  • 42
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.

Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143
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.

Shomari
  • 625
  • 4
  • 17
  • Not sure where I would plug the ABI at https://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..

    https://etherscan.io/address/0x5c63f39790dff3e115494f1d70e2ac3a36caa4ac#code The actual inputs passed to the deployed contract as consructor arguments were the following parameters 1000000,0,MARIA CANJE,CANJE,0xfDDEdAaa4a86B0B68Fd85D77E8399D0Fe8264289

    – Dino Anastos Oct 08 '17 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.

Surinder kumar
  • 371
  • 3
  • 15