wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

etherscan-verify cannot verify a contract while hardhat-etherscan can #264

Open ClementWalter opened 2 years ago

ClementWalter commented 2 years ago

Describe the bug

The etherscan-verify task fails with or without the --solc-input flag but using hardhat verify address args with the address and args found in the deployments/rinkeby does work.

To Reproduce

Contract is here: https://rinkeby.etherscan.io/address/0x6FA9f768110182eebB4fD086074C5b460BFE103E

This is the error message:

verifying DreamersRenderer (0x6FA9f768110182eebB4fD086074C5b460BFE103E) ...
waiting for result...
Failed to verify contract DreamersRenderer: NOTOK, Fail - Unable to verify
{
  "apikey": "XXXXXX",
  "module": "contract",
  "action": "verifysourcecode",
  "contractaddress": "0x6FA9f768110182eebB4fD086074C5b460BFE103E",
  "sourceCode": "...",
  "codeformat": "solidity-standard-json-input",
  "contractname": "contracts/dreamers/DreamersRenderer.sol:DreamersRenderer",
  "compilerversion": "v0.8.4+commit.c7e474f2",
  "constructorArguements": "00000000000000000000000079cfaa14901045e4564a5dadb34de81dc9efb871000000000000000000000000651534a85763beb8b6d04b86c96be724a2d3b8cf",
  "licenseType": 3
}
Falling back on solcInput. etherscan seems to sometime require full solc-input with all source files, even though this should not be needed. See https://github.com/ethereum/solidity/issues/9573
verifying DreamersRenderer (0x6FA9f768110182eebB4fD086074C5b460BFE103E) ...
waiting for result...
Failed to verify contract DreamersRenderer: NOTOK, Fail - Unable to verify
{
  "apikey": "XXXXXX",
  "module": "contract",
  "action": "verifysourcecode",
  "contractaddress": "0x6FA9f768110182eebB4fD086074C5b460BFE103E",
  "sourceCode": "...",
  "codeformat": "solidity-standard-json-input",
  "contractname": "contracts/dreamers/DreamersRenderer.sol:DreamersRenderer",
  "compilerversion": "v0.8.4+commit.c7e474f2",
  "constructorArguements": "00000000000000000000000079cfaa14901045e4564a5dadb34de81dc9efb871000000000000000000000000651534a85763beb8b6d04b86c96be724a2d3b8cf",
  "licenseType": 3
}
Etherscan sometime fails to verify when only metadata sources are given. See https://github.com/ethereum/solidity/issues/9573. You can add the option --solc-input to try with full solc-input sources. This will include all contract source in the etherscan result, even the one not relevant to the contract being verified

Using hardhat-etherscan I am able to verify:

npx hardhat --network rinkeby verify 0x6FA9f768110182eebB4fD086074C5b460BFE103E 0x79cfaa14901045e4564A5DAdb34DE81dC9efB871 0x651534a85763beB8b6D04b86C96BE724a2D3b8cf
Nothing to compile
No need to generate any newer typings.
Compiling 1 file with 0.8.4
Successfully submitted source code for contract
contracts/dreamers/DreamersRenderer.sol:DreamersRenderer at 0x6FA9f768110182eebB4fD086074C5b460BFE103E
for verification on Etherscan. Waiting for verification result...

Successfully verified contract DreamersRenderer on Etherscan.
https://rinkeby.etherscan.io/address/0x6FA9f768110182eebB4fD086074C5b460BFE103E#code

versions hardhat-deploy [e.g. 0.9.14] : 0.9.24 hardhat : 2.8.0 nodejs : v17.3.0 @nomiclabs/hardhat-etherscan : 2.1.8

Additional context

tuler commented 2 years ago

Maybe it's the same error as in https://github.com/wighawag/hardhat-deploy/issues/253

RomualdH commented 2 years ago

Hey there! I'm experiencing the same issue with both etherscan-verify from hardhat-deploy and hardhat-etherscan on the Polygon Mumbai network: contract XXX failed to submit : "NOTOK" : "Unable to process the standard-input-json you uploaded" [object Object]. I also tried manually on the Source Code Verfication Submission API without success.

However Sourcify does work.

wighawag commented 2 years ago

@RomualdH does it work with hardhat verify address args like the OP here ?

if not, it might be an issue with polygonscan.

Please provide more details

The annoying thing about etherscan is that we are dealing with a black box. Might be worth contacting them too

RomualdH commented 2 years ago

@RomualdH does it work with hardhat verify address args like the OP here ?

Doesn't work with hh verify --network POLYGON_test --constructor-args arguments.js MY_CONTRACT_ADDRESS.

Will send an email to PolygonScan team.

0xV4L3NT1N3 commented 2 years ago

gm all, will be joining in this thread from Etherscan.

@RomualdH do you have a Solidity Json Input gist we can try to reproduce with the verify demo page ?

RomualdH commented 2 years ago

@RomualdH do you have a Solidity Json Input gist we can try to reproduce with the verify demo page ?

Please find attached the file used when verifying the contract Bank:

032b0ad4389193ad4474f59592602137.txt

0xV4L3NT1N3 commented 2 years ago

Thanks for the contract address and Json Input, we are able to reproduce the error message on our end too.

It does not exceed the upload size limit of 3MB, eyeballing the JSON formatting looks fine too.

@RomualdH would you be able to attach a repo for the original source files as well ?

RomualdH commented 2 years ago

@RomualdH would you be able to attach a repo for the original source files as well ?

Sure, it has been verified on Sourcify: https://repo.sourcify.dev/contracts/full_match/80001/0x35fd0516074d4735FEA7Ee7eDC69176B2CfCB42a/sources/contracts/bank/

RomualdH commented 2 years ago

Hi @0xV4L3NT1N3 I deployed new contracts, the source code is here, but impossible to verify the Bank, Dice, CoinToss, Referral on PolygonScan Mumbai. We target a mainnet launch in less than 10 days. Hope this will not happen on mainnet...

Thank you in advance!

0xV4L3NT1N3 commented 2 years ago

Thanks for the additional deployed contracts and source, tried them on my end and I seem to getting very different bytecode comparisons.

Could you verify that your contracts were compiled using solc 0.8.11 with no optimization enabled as per the Hardhat config file ?

RomualdH commented 2 years ago

Could you verify that your contracts were compiled using solc 0.8.11 with no optimization enabled as per the Hardhat config file ?

The verification is working when setting the optimizer runs to a lower number. Thanks!

stephancill commented 1 year ago

I'm also struggling with this issue. Verifies fine on Sourcify. Disabling optimization doesn't help. I've tried with a bunch of different solidity versions with no luck. Any ideas?

usgeeus commented 6 months ago

What is the approximate maximum number of runs allowed when verifying? Does anyone know? @RomualdH

hazae41 commented 4 months ago

What is the approximate maximum number of runs allowed when verifying? Does anyone know? @RomualdH

It's 100000000