Etherscan – Verifying Token Contract on Rinkeby with Brownie

browniecontract-verificationetherscanrinkeby

I am testing my new token contract on Rinkeby. The contract was compiled and deployed using Brownie. I am deploying the token to Rinkeby and it is compiled and deployed correctly.

However, when I try and verify my contract on Etherscan, it keeps failing with the following error:

Error! Unable to generate Contract ByteCode and ABI

Found the following ContractName(s) in source code:
Context.sol:Context, IERC20.sol:IERC20, Token.sol:Token

But we were unable to locate a matching bytecode (err_code_2)

My contract consists of multiple files (3 to be exact) and I am using Solidity compiler version 0.8.1.

I tried compiling and deploying with Byzantium, Constantinople and Istanbul EVMs. But I keep getting the same error.

I cannot use the publish_source parameter when deploying with Brownie as that requires an API key and to my knowledge there are no API keys for Etherscan Rinkeby.

Am I missing something? Or is verification not possible on Etherscan Rinkeby?

Best Answer

Short answer is: you have to create the API key at etherscan.io either for the mainnet and the rest of public testnets (Ropsten, Rinkeby, Goerli..).

(Bonus)

In addition, I had some issues when trying to verify a contract with interfaces located in subdirectories.

Perhaps it is not your case, but if you are using Truffle to manage the contracts deployment, there is an interesting plug-in to verify the contract automatically: truffle-plugin-verify.

I tried it and it worked perfectly. You essentially need to

  • Install the truffle & plugin via npm
  • Create an API key on Etherscan
  • Update the truffle configuration file
  • Use a wallet to sign the transaction to create the contract (e.g.: @truffle/hdwallet-provider)
  • Migrate, and finally, verify the contract
Related Topic