Cannot verify contract on Binance Smart Chain deployed with Remix after using Truffle flattener

:memo:Details

Deployed smart contract over remix onto the binance smart chain and am now trying to verify the code. I used truffle flattener and tried uploading that file and get the following errors:

myc:414:1: DeclarationError: Identifier already declared.
interface IERC20 {
^ (Relevant source part starts here and spans across multiple lines).
myc:41:1: The previous declaration is here:
interface IERC20 {
^ (Relevant source part starts here and spans across multiple lines).
myc:502:1: DeclarationError: Identifier already declared.
library SafeMath {
^ (Relevant source part starts here and spans across multiple lines).
myc:264:1: The previous declaration is here:
library SafeMath {
^ (Relevant source part starts here and spans across multiple lines).

I then thought the next step would be to delete the duplicates, but then I was getting an error after that saying the bytecode is not similar was expecting …

:computer: Environment
Truffle v5.1.65, Windows 10, Remix, Binance Smart Chain

:1234: Code to reproduce
working with the following contract:

required Openzeppelin import links:
import “https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/math/Math.sol”;
import “https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/token/ERC20/IERC20.sol”;

1 Like

Just like we had said before, we are not familiar with BSC-Chain(at least for me), anything specific for BSC you can try asking in their community: https://community.binance.org/category/44/en-binance-smart-chain .

If you have no idea, maybe you can paste all code in a file manually, it is a bad idea, but I think it will work.

1 Like

Hi @jing,

You can try converting your GitHub imports to npm imports and then flattening your contract using a flattener, or if the Block explorer support, place a copy of each contract (including imports) into a single directory and try verifying that way.

I just had to choose the dropdown for optimization, since in remix the checkbox was checked for optimization

1 Like