繁体   English   中英

在以太坊测试网上部署我的 erc20 令牌时出现编译器调试错误

[英]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 来调用该函数。 但是,如果您的库包含内部函数,那么这些函数将内联到合约的字节码中。 所以,你有两个选择:

  1. 将库函数的可见性更改为internal
  2. 在测试网上部署库并链接到合约的字节码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM