Verifying with ABIEncoderV2 troubles
See original GitHub issueHi there,
Trying to verify some contracts using ABIEncoderV2 and I seem to be running into trouble. Here is a simple repo demonstrating the issue.
https://github.com/mrwillis/abiencoder-truffle-verification
I read in the README the pragma experimental ABIEncoderV2 has to come before the solidity pragma, but I’ve tried both orders and neither seems to work. Have also tried using a higher solidity version (0.6.11), but also fails.
Any ideas?
Output using debug:
julian@julian-wilson:~/betx/abiencoder-truffle-verification$ truffle run verify MetaCoin --network rinkeby --debug DEBUG logging is turned ON Running truffle-plugin-verify v0.3.11 Verifying MetaCoin Reading artifact file at /home/julian/betx/abiencoder-truffle-verification/build/contracts/MetaCoin.json Retrieving constructor parameters from https://api-rinkeby.etherscan.io/api?apiKey=[key]&module=account&action=txlist&address=0x9E8C724d9EAf24C34CcA3bDC7De469492051af84&page=1&sort=asc&offset=1 Constructor parameters received: 0x Flattening source file /home/julian/betx/abiencoder-truffle-verification/contracts/MetaCoin.sol Sending verify request with POST arguments: { “apikey”: “[key]”, “module”: “contract”, “action”: “verifysourcecode”, “contractaddress”: “0x9E8C724d9EAf24C34CcA3bDC7De469492051af84”, “sourceCode”: “pragma solidity 0.5.16;\npragma experimental ABIEncoderV2;\n\n\n// SPDX-License-Identifier: MIT\nlibrary ConvertLib {\n\tfunction convert(uint amount,uint conversionRate) internal pure returns (uint convertedAmount)\n\t{\n\t\treturn amount * conversionRate;\n\t}\n}\n\n// SPDX-License-Identifier: MIT\n// This is just a simple example of a coin-like contract.\n// It is not standards compatible and cannot be expected to talk to other\n// coin/token contracts. If you want to create a standards-compliant\n// token, see: https://github.com/ConsenSys/Tokens. Cheers!\ncontract MetaCoin {\n\tmapping (address => uint) balances;\n\n\tevent Transfer(address indexed _from, address indexed _to, uint256 _value);\n\n\tconstructor() public {\n\t\tbalances[tx.origin] = 10000;\n\t}\n\n\tfunction sendCoin(address receiver, uint amount) public returns(bool sufficient) {\n\t\tif (balances[msg.sender] < amount) return false;\n\t\tbalances[msg.sender] -= amount;\n\t\tbalances[receiver] += amount;\n\t\temit Transfer(msg.sender, receiver, amount);\n\t\treturn true;\n\t}\n\n\tfunction getBalanceInEth(address addr) public view returns(uint){\n\t\treturn ConvertLib.convert(getBalance(addr),2);\n\t}\n\n\tfunction getBalance(address addr) public view returns(uint) {\n\t\treturn balances[addr];\n\t}\n}”, “codeformat”: “solidity-single-file”, “contractname”: “MetaCoin”, “compilerversion”: “v0.5.16+commit.9c3226ce”, “optimizationUsed”: 1, “runs”: 200, “constructorArguements”: “” } Checking status of verification request 3vngcqycsnakc8wa4i92bbg5imqtdsw7byksdcfibmfwtvcyt5 Fail - Unable to verify Failed to verify 1 contract(s): MetaCoin
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)

Top Related StackOverflow Question
Hey @Enigmatic331 I have been working on allowing the user to provide their license manually (
--license MIT). And using @mrwillis’ example repo I ran into the issue that the source code is failing the verification through truffle-plugin-verify and through the Api demo page, but succeeding the verification on the web form.This is the data sent to the API:
The address above is not verified yet, so you can use it in testing. Since the
--licensestuff is currently just WIP, it’s not published anywhere it might be difficult to test for you guys. Let me know if you want me to publish a “beta” tag to NPM or something.Hey @mrwillis, I must have completely missed the notification for this issue, apologies!
One thing I noticed is that the flattened code contains two SPDX license identifiers, which is currently not working (see comments in #27). After removing it, the code still doesn’t seem to be verifying correctly. After updating the Solidity version to v0.6.11 like you mentioned before and moving the experimental pragma one line up, it now verifies correctly. I’m not sure what the cause of the failure is for v0.5.16, but if it is working correctly for v0.6, then that I’d say that is good enough.
So the main cause of this failure was probably the duplicate SPDX identifiers. I still need to come up with a good fix for that. Something I’m thinking might be to detect whether there are multiple identifiers, and if so, we strip out all of them and require the user to provide a license manually e.g.
--license MIT.