Verify ERC20 token on Etherscan that was deployed through remix

I am trying to verify the smart contract I deployed for my ERC20 token that was deployed through remix.

:computer: Environment
Used remix to deploy

:memo:Details
So far I have used these solutions -

  • Copy pasting imported files manually (bytecode doesn’t match).
  • Using truffle flattener (Multiple license error, after removing licenses, bytecode doesn’t match.

I have spent a few hours trying to figure it out to no avail.
Any help would be appreciated.

:1234: Code to reproduce

pragma solidity ^0.8.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";

contract SARToken is ERC20 {
    constructor() public ERC20("Saren", "SAR") {
        _mint(msg.sender, 1000000000 * (10 ** uint256(decimals())));
    }
}

1 Like

Hi @jaykch,

:warning: We should only use official releases of OpenZeppelin Contracts. When using GitHub imports we should always specify the tag of an official release.

Your contract was deployed using the master branch which is subject to change, so depending on when you deployed, this code could have changed, making it challenging to verify.

When did you deploy?

Remix now supports @ imports.

I recommend verifying using Hardhat (or Truffle if you deployed with Truffle) rather than flattening: Verify smart contract inheriting from OpenZeppelin Contracts. You convert your GitHub imports into npm imports, but you would need to know if your deployed code was part of a specific release.

Hi,

Thanks for getting back so quickly.
I deployed it yesterday through remix.

I have tried this as well -

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract SARToken is ERC20 {
    constructor() public ERC20("Saren", "SAR") {
        _mint(msg.sender, 1000000000 * (10 ** uint256(decimals())));
    }
}

I did not use any branch to deploy, I straight up copy pasted it in remix and deployed through metamask, first on kovan to test, then on mainnet.

Regarding the part of a specific release, do you mean the release for openzeppalin?

1 Like

Hi @jaykch,

You could try verifying via Remix if you used @ imports.

To use OpenZeppelin Contracts 4 in your GitHub import you would specify:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.0.0/contracts/token/ERC20/ERC20.sol

I would use Hardhat to verify, it should be straight forward.

I know that I should specify but I didn’t and I did not use @imports,

This is the exact code I posted on remix and deployed

pragma solidity ^0.8.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";

contract SARToken is ERC20 {
    constructor() public ERC20("Saren", "SAR") {
        _mint(msg.sender, 1000000000 * (10 ** uint256(decimals())));
    }
}

Hardhat is asking for mnemonic, and I used a ledger to do it and don’t feel comfortable adding it there cause the coins are worth a lot at the moment.

I will leave this post up if anyone can figure out how to verify this contract.

Edit: So I verified it through remix and I got contract verified successfully but it is not showing on etherscan. I will get back here if it doesn’t update.

1 Like

Alright so remix verification plugin did not work but the way I was able to verify was through manually adding all the imports removing all license and pragma solidity lines and then submitting on etherscan form.

Hope this helps people in future.

1 Like