Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created a token and I get an error when trying to verify: Error! Unable to generate Contract ByteCode and ABI #1248

Open
zueljin opened this issue Apr 30, 2021 · 2 comments

Comments

@zueljin
Copy link

zueljin commented Apr 30, 2021

Hello, I used a youtube tutorial to create a token on the Binance smart chain and have been distributing it to my community for rewards and role designation in discord. I want to get it verified so that I can add add an image to it through bscscan but I'm getting an error:

Error! Unable to generate Contract ByteCode and ABI
Found the following ContractName(s) in source code : Token
But we were unable to locate a matching bytecode (err_code_2)

I've never coded anything before this in my life before this and have very little knowledge about what anything means in the code. It compiles correctly on Remix 0.8.2 but will not verify. I've also tried optimization enabled and disabled with the same result. I'll paste it below for your review. I heard flattening it may resolve it but I couldn't figure out how to use truffle-flattener. Any help is appreciated

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.2;

contract Token {
mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance;
uint public totalSupply = 10000000 * 10 ** 18;
string public name = "Zuelyen";
string public symbol = "ZYN";
uint public decimals = 18;

event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);

constructor() {
    balances[msg.sender] = totalSupply;
}

function balanceOf(address owner) public view returns(uint) {
    return balances[owner];
}

function transfer(address to, uint value) public returns(bool) {
    require(balanceOf(msg.sender) >= value, 'balance too low');
    balances[to] += value;
    balances[msg.sender] -= value;
    emit Transfer(msg.sender, to, value);
    return true;
}

function transferFrom(address from, address to, uint value) public returns(bool) {
    require(balanceOf(from) >= value, 'balance to low');
    require(allowance[from][msg.sender] >=value, 'allowance too low');
    balances[to] += value;
    balances[from] -= value;
    emit Transfer(from, to, value);
    return true;
}

function approve(address spender, uint value) public returns(bool) {
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}

}

@aderdzinski
Copy link

Any luck on resolving this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@aderdzinski @zueljin and others