微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 BSC Scan 上验证和发布合同

如何解决无法在 BSC Scan 上验证和发布合同

我正在尝试在 BSC Scan 测试网上验证和发布合同。 我正在使用 Open Zepellin 和 Remix - ETH IDE,但是出现以下错误

未找到:不支持文件导入回调

如果我尝试在 Etherscan 上验证它,我相信同样的问题是真实的。

我做错了什么?

Contract Link

这是我贴在 BSC Scan 上验证并发布的代码

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract Presidente is ERC20,Ownable {
    constructor() ERC20("Presidente","PRES") {
        _mint(msg.sender,1000000 * 10 ** decimals());
    }

    function mint(address to,uint256 amount) public onlyOwner {
        _mint(to,amount);
    }
}

这是我得到的完整错误

enter image description here

解决方法

我看到您正在尝试验证,而您的合同需要展平,

这是你需要做的:

  1. 转到 remix.ethereum.org 并创建一个新文件 token.sol

  2. 复制/粘贴您的代码并保存

  3. 转到最后一个标签插件管理器并寻找FLATTENER安装

  4. FLATTENER 将显示为一个标签,点击它并按下 Flatten token.sol

  5. 按另存为 token_flat.sol

  6. 返回第一个选项卡,您将找到新文件

  7. 删除所有显示为“// SPDX-License-Identifier: MIT”的额外许可证

  8. 移动第二部分成为他们的部分

    pragma solidity ^0.8.0;

    /**

    • @dev 来自 ERC20 标准的可选元数据函数的接口。

    • 自 v4.1 起可用。 / 接口 IERC20Metadata 是 IERC20 { /*

      • @dev 返回令牌的名称。 */ function name() 外部视图返回(字符串内存);

      /**

      • @dev 返回令牌的符号。 */ function symbol() 外部视图返回(字符串内存);

      /**

      • @dev 返回令牌的小数位。 */ 函数小数()外部视图返回(uint8); }

    // 文件:@openzeppelin/contracts/token/ERC20/IERC20.sol

在这部分之后

    pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient,uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner,address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender,uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,address recipient,uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from,address indexed to,uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner,address indexed spender,uint256 value);
}

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
  1. 编译,你会很高兴

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?