Cannot verify ERC20 contract


I apologize for opening another topic on this, but I simply cannot solve this issue. I’ve deployed and verified contracts before, yet not using OpenZeppelin. What I did in my contract is to import these files (please observe that I did not use the local import @ style):

Everything compiled well in Remix, I’ve deployed the contract and it works. Yet I cannot verify it, because import clauses are not allowed on etherscan. I’ve installed truffle to compile and flatten the file, yet I had to install OpenZeppelin contracts, and I had to change my contract to use the @import (no other changes).

import “@openzeppelin/contracts/token/ERC20/ERC20.sol”;
import “@openzeppelin/contracts/token/ERC20/SafeERC20.sol”;
import “@openzeppelin/contracts/math/SafeMath.sol”;

Truffle compiles and I used truffle-flattener. I’ve set the same values in etherscan verify as in Remix, compiler 0.6.6+commit.6c089d02, no optimizations (I’ve tried with) and 200 Runs. I have no constructor in my contract, yet ERC20 does!!!

I have masked the name of my contract, not entirely sure why. If that would be important I can provide it.

The bytecode that “what we are looking for” is ~7000 bytes larger than “what we got”…

Please help!

1 Like

I’ve tried one more thing. I did attempt a multifile verification where I created in the same folder the following contracts: Address.sol, ERC20.sol, IERC20.sol, SafeERC0.sol, SafeMath.sol and imported them with “./xxx.sol”. Truffle compiles, no issues. I did not flatten the file, rather I used multi-file upload. Now the difference between what we are looking for/what we got is 299 bytes, which makes sense since the split in files took place. The differences are nearly at the end of the two bytecode strings, yet it does not look like a zero padded constructor. I have no constructor in my code.

Could it really be that I have not saved the right file and the code is different from what I’ve published even by a tiny fraction?

1 Like

Managed to solve the issue. Had to use e.g. this link:
I’ve downloaded each file, and made a multi-file verification again. This time everything worked fine. It looks like the OpenZeppeling file versions I’ve used during the initial deployment were different than the ones I had been using in truffle when setting up the code again for verification.

People should avoid importing like this:

import “

1 Like

Hi @kaenderr,

Welcome to the community :wave:

I am sorry you had issues verifying.

I recommend specifying the release tag when importing from GitHub, otherwise you will get the latest code in the master branch which could change over time. See the Remix documentation:

For multi-file verification I recommend using the following method to verify contracts: Verify smart contract inheriting from OpenZeppelin Contracts

Feel free to ask all the questions that you need.