Solidity
嘗試驗證契約時出錯
我正在嘗試驗證 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; } }
我也遇到了這個錯誤,這很有效:
- 刪除
artifacts
和cache
文件夾- 跑
npx hardhat compile
- 然後驗證
我剛剛又用了
npm install --save-dev @nomiclabs/hardhat-etherscan