[英]I'm getting compiler debug error while deploying my erc20 token on etherium testnet
编译器调试日志:错误! 无法生成合同字节码和 ABI 在源代码中找到以下合同名称:SafeMath, Token 但我们无法找到匹配的字节码 (err_code_2) 对于故障排除,您可以尝试使用 Remix - Solidity IDE 和检查异常
这是我的代码:
//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];
}
这是因为您的safetmath
库包含公共函数。 如 Solidity 文档中所述,如果您的库包含公共函数,则 EVM 将使用 DELEGATECALL 来调用该函数。 但是,如果您的库包含内部函数,那么这些函数将内联到合约的字节码中。 所以,你有两个选择:
internal
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.