Unable to generate Contract ByteCode and ABI • BSC

1st and foremost excuse my ignorance with this post. After reading through the same topic and comments a few times I still don't get the "how" to resolve this. I've created my first token and getting an error when validating. I have not flattened the code, I don't know how to. How do i go about this all? Appreciate any help. Below is the information in hopes of some assistance.

Token contract: 0xa6ca6e5dbdcf71bb195d41e82f27dd3eef73b0e6

:computer: Environment* on remix.ethereum.org
Contract: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol

:memo:Details
When I attempt to verify I get:

Compiler debug log:
Error! Unable to generate Contract ByteCode and ABI (General Exception, unable to get compiled [bytecode])

Compiler Warning(s):

ParserError: Source "ERC20.sol" not found: File import callback not supported
--> bep-20.sol:5:1:
|
5 | import "./ERC20.sol"
| ^^^^^^^^^^^^^^^^^^^^^

  • Compiler Version: v0.8.1+commit.df193b15
  • Optimization Enabled: False
  • Runs: 200

ByteCode (what we are looking for) :
Numbers

  • vs what we got -
    Token Name
    Same set of numbers

Ticker Name
Same set of numbers

:1234: Code to reproduce what i created as a bep-20.sol file

pragma solidity ^0.8.0;

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

contract DadeCounty is ERC20 {
    constructor(uint256 initialSupply) ERC20 ("Dade County", "DADE"){
        _mint(msg.sender,initialSupply);
    }
}

Hopefully this isn't a complete disaster and can be salvaged. Thanks again.

1 Like

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:

1 Like

Hi Skyge, thanks for the response. I’ve seen you in many posts with a lot of great assistance. I went ahead and created an account on bsc and searched for the same issue. This forum has more activity and responses.

I think for OpenZeppelin, not only do they devote themselves to audit contract system to protect products, but build many useful tools, such as:

And for this forum, this is a platform to help developers solves their problems.

If you are using OpenZeppelin Contract in remix, try to replace the outside file location like this, in your case is github : @openzeppelin/contract

1 Like

Hi, Magnus, have you solved your problems?

Hi Skyge, not yet. I got 99 problems and this contracts 1 lol

2 Likes

So you still can not verify your contracts, even though following their documentation? Okay, let me have a check.

2 Likes

Hey Skyge, so i was able to flatten the code in remix and upload it. It didn’t work. I’ve downloaded hardhat and giving it a go. Wish me luck. I’ll follow up.

2 Likes

Finally got it validated Flattened the code and use a site to generate the abi code. It worked.
Thanks you Skyge for the support. Now that I have the coin validated I have to venture into whats next.

3 Likes

hi, what are you using to generate the abi code ? I found one website to generate it but don’t work for me
thanks

1 Like

For Bytecode go to Remix > Recompile the Code > Copy the ABI > Go to https://abi.hashex.org/ and paste it > enter the total token supply and Parse > Copy the code and paste it while scanning for constructor.

Hope this helps!

1 Like

I have the same problem and I can’t solve it. Even recompiling the API doesn’t appear to me when copying. The code appears empty.

@Carlos_Eduardo @Voxy Have you solved your problem? If you want to verify the contract, maybe you can have a look at this tutorial;

Hi Magnus,
I found a solution! Just change your import... refer below

The key is:

  1. Use import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
  2. do not use import http link, it will work on Remix
  3. Use Remix flattener plug in to flatten the file.
  4. Remove all the extra pragma and license
  5. Might have some error due to sequence of each openzeppelin code chunk, just re-organize it.
  6. deploy the flattened .sol file
  7. On BSCscan page, use single file verification
  8. Copy the flattened .sol
  9. Do not use optimization
  10. Should be ok. I get it verified on testnet and mainnet
    https://testnet.bscscan.com/address/0x718c35c014f8cdc2b6ee810dab44a4da8cb40887#code
    https://bscscan.com/address/0x07dafaf783bc253ac310692856e863b659d8f3ca#code
1 Like

hi skyge pls am having the same problem but when I try to copy the ABI code to paste it on this address https://abi.hashex.org/ i got something like these "open and close brace". after pasting it. how can i solve this problem

So what is your function ABI?

11 posts were split to a new topic: Unable to generate contract bytecode Ethereum

My issue is resolved thanks for your responses

1 Like

A post was merged into an existing topic: Unable to generate contract bytecode Ethereum