1

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

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

如果我尝试在 Etherscan 上进行验证,我相信同样的问题也是如此。

我究竟做错了什么?

合约链接

这是我粘贴在 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);
    }
}

这是我得到的完整错误 在此处输入图像描述

4

1 回答 1

1

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

这是你需要做的:

  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. 移动第二部分成为他们的部分

    编译指示 ^0.8.0;

    /**

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

    • 从 v4.1 开始可用。 / 接口 IERC20Metadata 为 IERC20 { / *

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

      /**

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

      /**

      • @dev 返回令牌的小数位。*/ function decimals() 外部视图返回 (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. 编译,你会很高兴的
于 2021-07-01T19:40:12.840 回答