在使用$ npx hardhat初始化之后,我在部署时遇到了问题。
HardhatError: HH700: Artifact for contract "" not found.我可以编译没有错误的契约,$ npx hardhat compile,但是当我试图使用部署脚本部署它时,我得到了错误:
$nnpx hardhat run scripts/deploy.js --network rinkeb
HardhatError: HH700: Artifact for contract "" not found.在我的hardhat.config.js中,我有这样的路径:
sources: "./contracts",
artifacts: "./artifacts",
cache: "./cache"
},在部署脚本deploy.js中
const NFT = await hre.ethers.getContractFactory("contract");
const nft = await NFT.deploy();
await nft.deployed();我把合同保存在contracts/contract.sol里了。
我不知道哪个是问题所在。
发布于 2021-11-28 18:00:59
我想办法找出出了什么问题。合同文件名和合同定义不同。我不知道合同的文件名和合同定义是否必须相同。
在contracts/contract.sol中,我有:
pragma solidity ^0.8.0;
imports ...
contract NTFContract is ERC1155, Ownable {...
}在重命名contracts/contract.sol --> contracts/NTFContract.sol之后,我不再有这个问题了,我能够正确地部署它。
我仍然在想,一般来说,哪一种习俗是坚固的,哪一种是安全帽的。
发布于 2022-05-30 12:00:41
如果以前使用不同的文件名进行编译,则可能会导致错误的缓存数据失效。您可以尝试重新构建缓存以清除问题。
$ npx hardhat clean ; npx hardhat compile快易,值得一试
发布于 2022-04-12 01:29:43
“在重新命名了contracts/contract.sol --> contracts/NTFContract.sol之后,我不再有这个问题了,我能够正确地部署它。”
确保在缓存/solidity cache.json中也更改了文件名,否则即使重命名后错误也会持续。
https://ethereum.stackexchange.com/questions/114503
复制相似问题