Solidity

嘗試驗證契約時出錯

  • April 18, 2022

我正在嘗試驗證 pn Etherscan 我的契約,但收到此錯誤。會是什麼呢?

PS C:\Projects\HardHat TS2> npx hardhat verify --network rinkeby 0x9517F72c4b61A07fd0cF684eE7A74C18Eb36dad8
Nothing to compile
No need to generate any newer typings.
An unexpected error occurred:

[Error: ENOENT: no such file or directory, open 'C:\Projects\HardHat TS2\artifacts\build-info\bd5e1b48863d1c1801c0a0353cc35891.json'] {
 code: 'ENOENT',
 syscall: 'open',
 path: 'C:\\Projects\\HardHat TS2\\artifacts\\build-info\\bd5e1b48863d1c1801c0a0353cc35891.json'
}

契約核實

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract NFT is ERC721URIStorage {
   constructor() ERC721("NFTforMarket", "NFT") {}

   using Counters for Counters.Counter;
   Counters.Counter private _tokenIds;

   function mint(string memory tokenURI) public returns (uint256) {
       uint256 newItemId = _tokenIds.current();
       _mint(msg.sender, newItemId);
       _setTokenURI(newItemId, tokenURI);
       _tokenIds.increment();
       return newItemId;
   }
}

我也遇到了這個錯誤,這很有效:

  1. 刪除artifactscache文件夾
  2. npx hardhat compile
  3. 然後驗證

我剛剛又用了npm install --save-dev @nomiclabs/hardhat-etherscan

引用自:https://ethereum.stackexchange.com/questions/121176