【问题标题】:Verify and Publish Contract on Etherscan with Imported OpenZeppelin file使用导入的 OpenZeppelin 文件在 Etherscan 上验证和发布合约
【发布时间】:2021-08-14 11:01:46
【问题描述】:

我目前正在构建符合 ERC721 的合约并已在此处发布该合约:https://ropsten.etherscan.io/address/0xa513bc0a0d3af384fefcd8bbc1cc0c9763307c39 - 我现在正在尝试验证和发布合约源代码

我的文件的开头是这样的:

// SPDX-License-Identifier: MIT

// We will be using Solidity version 0.8.4
pragma solidity 0.8.4;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract ViperToken is ERC721 {

但是,当尝试使用 Solidity 单个文件进行验证和发布时,出现以下错误:

ParserError: Source "@openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File import callback not supported
 --> myc:6:1:
  |
6 | import "@openzeppelin/contracts/token/ERC721/ERC721.sol"
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

谁能指出我的方向 1. 解决这个问题或 2. 关于如何正确编写具有可以使用 Etherscan 验证的导入依赖项的合同的文档。现在这只是一个单一的文件合同。

【问题讨论】:

    标签: ethereum solidity smartcontracts cryptocurrency etherscan


    【解决方案1】:

    简单地说,因为我对 Solidity 还很陌生,所以我不得不陷入困境来解决这个问题。

    我必须做以下事情;

    1. 学习和使用 https://www.trufflesuite.com/ 来设置项目并将我的合同放在那里(使用 Ganache 对任何刚接触 Solidity 的人也有很大帮助)
    2. 使用 HD Wallet 提供程序包并按照此处的教程在 ropsten Etherscan https://medium.com/coinmonks/5-minute-guide-to-deploying-smart-contracts-with-truffle-and-ropsten-b3e30d5ee1e 上获取它
    3. 最后,使用 truffle-plugin-verify https://github.com/rkalis/truffle-plugin-verify 在 Etherscan 上验证合约

    总而言之,我很确定在 Etherscan Web 应用程序中无法验证包含导入文件的合约。

    如果有人有兴趣了解我是如何构建它的https://github.com/lukecurtis93/viper-nft,那么最终产品就在这里(它只是我在网上找到的一个 CryptoKitties 克隆作为基础并对其进行了全部更新)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-12
      • 2021-11-15
      • 2022-07-07
      • 1970-01-01
      • 2021-11-14
      • 2017-11-26
      • 2021-11-11
      • 1970-01-01
      相关资源
      最近更新 更多