Search code examples
soliditysmartcontractsetherscan

Error verifying Smart Contract via Etherscan API due to evmversion


I'm having an issue verifying contracts using Etherscan API when I use a different evm version from the standard compiler version.

In details I'm compiling using v0.8.21 and targeting to paris (for L2).

Once I submit verification via API like this:

curl --location 'https://api.etherscan.io/api' \
--form 'apikey="<MY-API-KEY>"' \
--form 'module="contract"' \
--form 'action="verifysourcecode"' \
--form 'contractaddress="<MY-CONTRACT ADDRESS>"' \
--form 'sourceCode="// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Storage
 * @dev Store & retrieve value in a variable
 */
contract Storage {

    uint256 number;

    /**
     * @dev Store value in variable
     * @param num value to store
     */
    function store(uint256 num) public {
        number = num;
    }

    /**
     * @dev Return value 
     * @return value of '\''number'\''
     */
    function retrieve() public view returns (uint256){
        return number;
    }
}"' \
--form 'contractname="Storage"' \
--form 'compilerversion="v0.8.21+commit.d9974bed"' \
--form 'optimizationUsed="1"' \
--form 'runs="200"' \
--form 'constructorArguements=""' \
--form 'evmversion="paris"' \
--form 'licenseType="3"'

I receive the following error:

Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

It also fails if I try from the API demo here https://etherscan.io/sourcecode-demo.html

But if I manually verify from contract page itself on etherscan website, it works.

I think it is not reading `evmversion` parameter right via API.

Have you had any similar issue?


Solution

  • It was an issue on etherscan, bscscan, polygonscan and it has been addressed. It is now working.

    Check that comment from etherscan team https://twitter.com/vittominacori/status/1712755736848052609