Error! Unable to generate Contract ByteCode and ABI

Hi,

I deployed my contract in etherscan, and now i want to do verifecation i get this problem, after a while tryning some solutions and tutorials but it is not helping me.

Any help please,

My contract address: 0x67a7c0e73475edb18db7fb2af6af847a33814f7b

Best Regards,

1 Like

Please share your code and the config to compile.

1 Like

Hi,

I deployed my contract using, Remix - Ethereum IDE !!

Iā€™m getting this issue ?!!

1 Like

Hi @Azghour-Saad,

Welcome to the community :wave:

You could try the following: Verify smart contract inheriting from OpenZeppelin Contracts

If you are flattening and need to encode constructor parameters you can use https://abi.hashex.org/

If you want help, then you would need to share your contract Solidity code, constructor parameters and whether optimization was used.

hi bro
sera que me puede echar una mano

pragma solidity ^0.4.24;

// ----------------------------------------------------------------------------
// Sample token contract
//
// Symbol        : STC
// Name          : STATE COIN
// Total supply  : 1000000000000000000000000
// Decimals      : 9
// Owner Account : 0x9876A5bc27ff511bF5dA8f58c8F93281E5BD1f21
//
// Enjoy.
//
// (c) by Jose Rivera 2021. MIT Licence.
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// Lib: Safe Math
// ----------------------------------------------------------------------------
contract SafeMath {

    function safeAdd(uint a, uint b) public pure returns (uint c) {
        c = a + b;
        require(c >= a);
    }

    function safeSub(uint a, uint b) public pure returns (uint c) {
        require(b <= a);
        c = a - b;
    }

    function safeMul(uint a, uint b) public pure returns (uint c) {
        c = a * b;
        require(a == 0 || c / a == b);
    }

    function safeDiv(uint a, uint b) public pure returns (uint c) {
        require(b > 0);
        c = a / b;
    }
}


/**
ERC Token Standard #20 Interface
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
*/
contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address tokenOwner) public constant returns (uint balance);
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);

    event Transfer(address indexed from, address indexed to, uint tokens);
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}


/**
Contract function to receive approval and execute function in one call

Borrowed from MiniMeToken
*/
contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}

/**
ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers
*/
contract STCToken is ERC20Interface, SafeMath {
    string public symbol;
    string public  name;
    uint8 public decimals;
    uint public _totalSupply;

    mapping(address => uint) balances;
    mapping(address => mapping(address => uint)) allowed;


    // ------------------------------------------------------------------------
    // Constructor
    // ------------------------------------------------------------------------
    constructor() public {
        symbol = "STC";
        name = "STATE COIN";
        decimals = 9;
        _totalSupply = 1000000000000000000000000;
        balances[0x9876A5bc27ff511bF5dA8f58c8F93281E5BD1f21] = _totalSupply;
        emit Transfer(address(0), 0x684Ff4eb70b9D7C2e071c3574A9514B95115238A, _totalSupply);
    }


    // ------------------------------------------------------------------------
    // Total supply
    // ------------------------------------------------------------------------
    function totalSupply() public constant returns (uint) {
        return _totalSupply  - balances[address(0)];
    }


    // ------------------------------------------------------------------------
    // Get the token balance for account tokenOwner
    // ------------------------------------------------------------------------
    function balanceOf(address tokenOwner) public constant returns (uint balance) {
        return balances[tokenOwner];
    }


    // ------------------------------------------------------------------------
    // Transfer the balance from token owner's account to to account
    // - Owner's account must have sufficient balance to transfer
    // - 0 value transfers are allowed
    // ------------------------------------------------------------------------
    function transfer(address to, uint tokens) public returns (bool success) {
        balances[msg.sender] = safeSub(balances[msg.sender], tokens);
        balances[to] = safeAdd(balances[to], tokens);
        emit Transfer(msg.sender, to, tokens);
        return true;
    }


    // ------------------------------------------------------------------------
    // Token owner can approve for spender to transferFrom(...) tokens
    // from the token owner's account
    //
    // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
    // recommends that there are no checks for the approval double-spend attack
    // as this should be implemented in user interfaces 
    // ------------------------------------------------------------------------
    function approve(address spender, uint tokens) public returns (bool success) {
        allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender, spender, tokens);
        return true;
    }


    // ------------------------------------------------------------------------
    // Transfer tokens from the from account to the to account
    // 
    // The calling account must already have sufficient tokens approve(...)-d
    // for spending from the from account and
    // - From account must have sufficient balance to transfer
    // - Spender must have sufficient allowance to transfer
    // - 0 value transfers are allowed
    // ------------------------------------------------------------------------
    function transferFrom(address from, address to, uint tokens) public returns (bool success) {
        balances[from] = safeSub(balances[from], tokens);
        allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
        balances[to] = safeAdd(balances[to], tokens);
        emit Transfer(from, to, tokens);
        return true;
    }


    // ------------------------------------------------------------------------
    // Returns the amount of tokens approved by the owner that can be
    // transferred to the spender's account
    // ------------------------------------------------------------------------
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
        return allowed[tokenOwner][spender];
    }


    // ------------------------------------------------------------------------
    // Token owner can approve for spender to transferFrom(...) tokens
    // from the token owner's account. The spender contract function
    // receiveApproval(...) is then executed
    // ------------------------------------------------------------------------
    function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
        allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender, spender, tokens);
        ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
        return true;
    }


    // ------------------------------------------------------------------------
    // Don't accept ETH
    // ------------------------------------------------------------------------
    function () public payable {
        revert();
    }
}

I am having the same issue as the OP. Please help. I deployed using Remix. Tried to verify on bscscan, and am getting the following errors:

Error! Unable to generate Contract ByteCode and ABI (General Exception, unable to get compiled [bytecode]) For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions

ParserError: Source ā€œ[ā€¦/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol]ā€ not found: File import callback not supported ā†’ myc:5:1:
5 | import ā€œ[ā€¦/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol]ā€ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Here is my contract code from Remix:

pragma solidity ^0.8.0;

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

contract Kibble is ERC20 {
    constructor(uint256 initialSupply) public ERC20 ("Kibble", "KIBL"){
        _mint(msg.sender,initialSupply);
    }
}

we got the same error

Flatten your files, you have multiple files.

Hi,

Could you explain to me what do you mean by flattening your files. I have the same exact issue.

hi i am unable to get rid of problem pls help me step by step

Hi, welcome! :wave:

I think you can have a look at this tutorial: Verify ERC20 token on Etherscan that was deployed through Remix: Step by Step Guide

Hi, welcome! :wave:

Actually, it depends on how would you like to verify your contracts, when you want to verify your contracts in a single file, then you will need to flatten all your contracts including the imported contracts into a single file to verify.

Hi,

yes i am having the same problem and have tried multiple avenues

Here is my code

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

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

contract uRED is ERC20{
    constructor()public ERC20("URED", "URED"){
        _mint(msg.sender, 233038348* (10** uint256(decimals())));
    }
}

Hi, so even though you have followed the tutorial I shred above, you still can not verify your contracts, right?

Please share your contract address, network, compiler version.

Here is the token address

0xc618caf054498235e6c3774a5cc4c445d8cc7201

Network:

Binance Smart Chain

Compiler:

0.6.12

Not sure, maybe you have others config, I just deployed a same contract, and it had been verified:

I would like to know what you do that other users do wrong, because many times the flattened contracts that compile perfectly in Remix but fail the verification.
And it seems that it is something random but it is not.
What do you think is the most common mistake we all make with it?
I haven't figured it out yet.

I think you can have a check at this tutorial:

Did You Find Something?

Did You Find Something I Have Same Problem?