Verify ERC20 token on Etherscan that was deployed through Remix: Step by Step Guide

At the previous tutorial: Create an ERC20 using Remix, without writing Solidity, we have learned how to deploy contracts with the Remix, and now in this tutorial, we will learn how to verify the deployed contracts by a single file.

Cause many people deploy contracts by the Remix, so in this part, we will use the plugin FLATTENER in the Remix to help us to package all contracts file into a single file to verify.

In short, all steps are:

  1. Compile contract
  2. Flatten contract
  3. Copy the whole code to verify on the Etherscan

Okay, next let us go through it step by step.

Compile contract

I think you have followed the previous tutorial to deploy the contracts by the Remix, but you should notice the network , compiler version and compiler configuration when you deployed the contract. In this part, what you need to do is just checking the option Auto compile to compile your contract automatically, as for the another option Enable optimization , it depends on you, at here, we will use it, so all just like the following:


NOTICE: your contracts should be compiled without any errors.

Flattern contract

We will use the plugin FLATTENER in the Remix to flatten all contracts into a single file. Firstly, click the Plugin manager on the left side of the page, then find the plugin FLATTENER in the Inactive Modules and click the button Activate to use it, just like:

Then the plugin FLATTENER will show at the left side of the page, click it and you will find the blue button Flatten YOUR_CONTRACT.sol , click it, and then click the bottom button Save YOUR_CONTRACT_flat.sol to save the flattened file, just like following:

it will ask your permission to save file, just click the Accept , it will show File saved , so click on the option in the upper left corner File explorers and then you will find the flattened file at the bottom, just like

Common Errors:

Cause we have checked the option Auto compile at the step 1, so when we click the flattened contract file, it will compile automatically. What we need to do is solving the errors after compiling if has. Generally, we will encounter the following two errors:

One is:

ParserError: Multiple SPDX license identifiers found in source file. Use "AND" or "OR" to combine multiple licenses. Please see for more information. --> contracts/OpenZeppelin.sol

For the current version, you need to remove the duplicate SPDX license manually, only keep one valid SPDX license. Here is some discussion of the issue: Deduplicate or remove SPDX license identifier comments

The other one is:

TypeError: Definition of base has to precede definition of derived contract --> OpenZeppelin_flat.sol:506:30: | 506 | abstract contract Ownable is Context { | ^^^^^^^

As for this, you should adjust the order of the contracts, that is putting the parent contract in front, and put child contract behind.
For example: the wrong code is:

abstract contract Ownable is Context{}
contract Context{}

The right order should be:

contract Context{}
abstract contract Ownable is Context{}

Here is an issue on the github about this error: Wrong contract order

Verify on the Etherscan

Nice! we are only one step away from success. Find the contract you have deployed on the Etherscan, click the option Contract and then click Verify and Publish , just like following:

Choose the right Compiler Type : Solidity(Single file)
Choose the right Compiler Version : YOUR_DEPLOYED_VERSION
Choose a right License Type .
just like following:

Click the button Continue to enter the next page, click the Optimization if you use it when you deploy, and then paste the flattened source code. Generally, Etherscan will upload constructor arguments automatically, but some times it will upload the wrong constructor arguments due to your constructor arguments are a little complex, so in this case, you can encode arguments by this tool: (if you do not know how to use it, you can have a look at this Verify Timelock contract on BSC | OpenZeppelin Community @Bsc_Talk, thanks for your detailed explanation) Finally, click the button Verify and Publish , just like following:

After waiting for a while, you can find out your contract has been verified successfully, congratulations! Like following:

This really has so many steps to do by this way, so I recommend you to read this tutorial to verify your contract:


this is gold! Thank you so much!



1 Like

I verified my contract now it`s checked green, i sign the contract, but i have this exclamation mark right next to Solidity Compiler Bugs:

Compiler specific version warnings:

The compiled contract might be susceptible to ABIDecodeTwoDimensionalArrayMemory (very low-severity), KeccakCaching (medium-severity), EmptyByteArrayCopy (medium-severity), DynamicArrayCleanup (medium-severity), MissingEscapingInFormatting (very low-severity), ImplicitConstructorCallvalueCheck (very low-severity), TupleAssignmentMultiStackSlotComponents (very low-severity), MemoryArrayCreationOverflow (low-severity), privateCanBeOverridden (low-severity) Solidity Compiler Bugs.

Now i seen other important Tokens that have this sorts of issues, now the question is : is this important for me to solve ? and if it is , how can i solve it? any hint would be great, thank you all!

Seems like you got some warings, I think you can follow the prompts to modify if it has. And some warings just wants to remind you know what are doing. Eg: it may say: loop to deep and may cost all gas, so you need to notice the length to loop. But actually for your contract, it just has two elements to loop. Anyway, you should know what dose this waring mean, and judge for yourself if it will affect you.

hi, you can help me?, i have two questions, first
how is the correct order in the contrascts than i need to solve this error:

TypeError: Definition of base has to precede definition of derived contract → OpenZeppelin_flat.sol:506:30: | 506 | abstract contract Ownable is Context { | ^^^^^^^ )

second: i do a ERC20 token in the mainnet network of matic as like this Create an ERC20 using Remix, without writing Solidity in this form of create the token i need to give ABI-encoded Constructor Arguments to verify? if the request is yes, ¿how i get that ABI-encoded Constructor Arguments?

PS: i need to add libraries here if the code is flatted ?

Hi, welcome! :wave:

Just adjust the position of the two contracts, eg:

contract Ownable is Context {}

contract Context {}

maybe you will get errors from above contracts, because your Ownable contract is inherited from contract Context, but it is defined after Ownable, so just place the Context in front, so it should be

contract Context {}

contract Ownable is Context {}

If your contract has constructor parameters, you need to encode, and you can use this tool: if not, do nothing.

thanks for you request Skyge

Having issues solving the following,

TypeError: Definition of base has to precede definition of derived contract → BEP-201_flat.sol:42:29: | 42 | interface IERC20Metadata is IERC20 { | ^^^^^^

Just like the the prompt says, and I also answered a similar question, you should make some changes manually, now your contracts are:

contract IERC20Metadata is IERC20 {}
contract IERC20 {}

Just move the contracts to make them like:

contract IERC20 {}
contract IERC20Metadata is IERC20 {}

You are Awesome @Skyge thanks for your answer, finally was able to verify my contract :slight_smile:


An excellent guide to all, and for people like me that are starting to deploy and verify contracts on Etherscan, Thank you @Skyge, finally was able to verify my first contract


Thanks Skyge.
It’s very helpful tutorial for me as beginner.

1 Like

Hi, I did everything I could and it still doesn’t work. Could you help me?

Contract: 0xa402e9e37518c1c9e3a79d448778385a8a401f0c

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "";

contract Bitelon is ERC20 {
    constructor(uint256 initialSupply) public ERC20 ("Bitelon", "BTE") {

Have you followed the guide? Where did it fail? What error did you get? Please be more specific or your questions will be flagged.

thank you guy it everything work fine


Thank you men . . . . . .

I have flattened the contract and checked in remix, everything ok,

I have followed the guide scrupulously

but at the time of verify and publish in the network deployed I get the following error

which is the same as the user @Devon who has solved the problem without commenting how.

1 Like