简体   繁体   English

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

[英]I'm getting compiler debug error while deploying my erc20 token on etherium testnet

Every time I'm trying to deploy my token contract on the test net, I'm facing this error:每次我试图在测试网上部署我的代币合约时,我都会遇到这个错误:

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:所以,你有两个选择:

  1. Change the visibility of your library functions to internal将库函数的可见性更改为internal
  2. Deploy the library on the testnet and link it to the bytecode of the contract在测试网上部署库并链接到合约的字节码

暂无
暂无

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

相关问题 将 ERC20 代币与其他 ERC20 代币交换 - Exchange ERC20 token with other ERC20 token 使用 ERC20 代币支付 - Paying with ERC20 token 如何在我的 Solidity 合约中使用我的 erc20 自定义代币作为所需付款? - How can I use my erc20 custom token as required payment in my solidity contract? 无法使用 Maticjs 通过 POS Bridge 桥接部署的 ERC20 令牌,出现此错误“执行已恢复:ERC20:批准到零地址” - Not able to bridge deployed ERC20 token through POS Bridge using Maticjs, getting this error "execution reverted: ERC20: approve to the zero address" 编译我的erc20令牌后,我可以修改任何功能吗? - After compiling my erc20 token, can I modify any function? 出现错误:返回错误:必须经过身份验证! ,同时使用 web3.js 发送 erc20 代码 - Getting Error: Returned error: Must be authenticated! , while sending erc20 code using web3.js Web3.js。 无法通过 Rinkeby 测试网发送 ERC20 代币? 终端说交易已被 EVM 还原 - Web3js. Can't send ERC20 Token over Rinkeby Testnet? Terminal says Transaction has been reverted by the EVM 我该如何退还我用来购买ERC20代币的以太币? - How can i send back the ether which i used to buy a token in ERC20? 使用web3 Ropsten Infura TestNet传输ERC20令牌 - Transferring ERC20 Tokens using web3 Ropsten Infura TestNet 我称之为SmartContract令牌ERC20,为什么显示哈希输出? - I Call SmartContract Token ERC20, Why Show Hashing Output?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM