Error verifying contract on etherscan, polygonscan, bscscan via api when using different evmversion

NOTE: This is not completely related to OZ library but as it is now required to compile using ^0.8.20 it may be useful for users who want to compile for L2.

I'm having an issue verifying contracts using Etherscan (Polygonscan|BscScan...) 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 '' \
--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

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

Also if I compile with shanghai and set evmversion="paris" in api call, it passes the verification but shows default compiler (that is shanghai for 0.8.21) on etherscan contract page. So that parameter is unuseful.

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

Have you had any similar issue?

1 Like

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