[英]I'm getting compiler debug error while deploying my erc20 token on etherium testnet
Compiler debug log: Error!
编译器调试日志:错误! Unable to generate Contract ByteCode and ABI Found the following ContractName(s) in source code: SafeMath, Token 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
无法生成合同字节码和 ABI 在源代码中找到以下合同名称:SafeMath, Token 但我们无法找到匹配的字节码 (err_code_2) 对于故障排除,您可以尝试使用 Remix - Solidity IDE 和检查异常
This is the image of error这是错误的图像
This is my code:这是我的代码:
//SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.7;
library SafeMath {
function Add(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function Sub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function Mul(uint a, uint b) public pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function Div(uint a, uint b) public pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
contract Token{
using SafeMath for uint256;
string public name = 'MY TOKEN';
string public symbol = 'MTK';
uint256 public decimals = 18 ;
uint256 public totalsupply = 10000000000000000000000 ;
address owner;
//5% will go to owner and 5% of transaction will burn
uint taxfee = 5;
uint burnfee = 5;
bool public istransferable = false;
//bool public ExcludedFromReward = false;
//exclude addresses from deflation
mapping(address=>bool) public ExcludedFromFee;
//mapping(address=>bool) public ExcludedFromReward;
mapping(address => uint256) public balance;
mapping(address => mapping(address => uint256)) allowance;
mapping (address => bool) public _Blacklisted;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event OwnershipTransfer(address indexed previousOwner, address indexed newOwner);
constructor(){//(string memory Name, string memory Symbol, uint Decimals, uint TotalSupply) {
// name = Name;
// symbol = Symbol;
// decimals = Decimals;
// totalsupply = TotalSupply;
owner = msg.sender;
balance[owner] = totalsupply;//TotalSupply;
ExcludedFromFee[owner] = true;
_rOwned[msg.sender] = _rTotal;
}
function Balance() public view returns(uint256) {
return balance[owner];
}
This is because your safetmath
library contains public functions.这是因为您的
safetmath
库包含公共函数。 As mentioned in the Solidity documentation, if your library contains public functions, then the EVM will use a DELEGATECALL to invoke the function.如 Solidity 文档中所述,如果您的库包含公共函数,则 EVM 将使用 DELEGATECALL 来调用该函数。 However, if your library contains internal functions, then those functions will be inlined in the bytecode of the contract.
但是,如果您的库包含内部函数,那么这些函数将内联到合约的字节码中。 So, you have two options:
所以,你有两个选择:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.