Tried everything to verify my Token on BSC Scan (Truffle-flattener etc.)

:computer: Environment

  • Remix.Ethereum with Solidity compiler 0.8.4.
  • OpenZeppelin [v4.1.0]
  • BSC ERC20

:memo:Details
Hi All, Hi Skyge,

I tried to verify my token created on BSC Scan yesterday but nothing worked so far. I followed the advices to use the truffle-flatenner and copy paste the code in BSC Scan but didn’t worked also.

@Skyge could you please help me out? :sweat_smile: I really gave my try for hours…hahaha the best I got so far was that the ByteCode were not identical (as it also detects ERC20 and PUROCIGARS in the code).

I guess it automatically used the OpenZeppelin [v4.1.0]

The token: 0xdd301479d8b6058fed4a177ff20a87c260be1701

Many thanks! @Skyge for you helpful work, posts and advices (that I tried to follow). :innocent:
Keep up the great OpenZeppelin work, project and community!.

:1234: Code to reproduce
I used OpenZeppelin and Remix.Ethereum with Solidity compiler 0.8.4, see below the short script:

pragma solidity ^0.8.4;

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

contract PUROCIGARS is ERC20 {
  constructor() ERC20('PURO', 'PRO') {
    _mint(msg.sender, 1000000 * 10 ** 18);
  }
}

Hi, welcome! :wave:

Sorry, I am not familiar with the BSC-Chain, maybe you should ask for help in their forum: Home | Binance Chain Forum

And they have a documentation about how to verify contracts, maybe you can have a look at it:

So when you tried to verify your contracts, what’s the error?

1 Like

Yep I tried the truffle verify also :(. Yes the tag ERC-20 was misleading in my post sorry. I also recompiled the truffle-flattener code with Remix.eth and doesn’t work :frowning:

Thankssss!

The error I get is the following:

Error! Unable to generate Contract ByteCode and ABI
Found the following ContractName(s) in source code : Context , ERC20 , IERC20 , IERC20Metadata , PUROCIGARS
But we were unable to locate a matching bytecode (err_code_2)
For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions

Contracts deployed with Remix are very difficult to verify on Etherscan. Can’t help with this contract but a couple of recommendations for next time:

  1. First deploy to a testnet and try to verify there.
  2. Instead of Remix consider using a tool like Hardhat with the hardhat-verify plugin to verify automatically.
2 Likes

You should try:

truffle run verify ERC20@0xdd301479d8b6058fed4a177ff20a87c260be1701 --network testnet

I use to have the same issue, Be contracts deployed with Remix are very difficult to verify my next token or you may apply next time too with the following:

  1. First deploy to a testnet.
  2. Try to verify with familiar tool like : truffle-plugin-verify
1 Like