我的代码一直存在这个错误,我提到了另一篇关于'Greeter.sol‘的类似问题的文章,但这似乎不是我的问题。
这是我的.sol文件代码:
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Btc is ERC20, Ownable {
constructor() ERC20("Dogecoin", "DOGE"){}
function mint(address to, uint256 amount) public payable{
_mint(to, amount);
}
receive() external payable{}
}以下是我一直在犯的错误:
HardhatError: HH700:没有找到合同"Dogecoin“的工件。(/home/muskaan/moti-milo/smart-contract/node_modules/hardhat/src/internal/artifacts.ts:478:11) at Artifacts._getArtifactPathFromFiles (/home/muskaan/moti-milo/smart-contract/node_modules/hardhat/src/internal/artifacts.ts:593:19) at Artifacts._getArtifactPath (/home/muskaan/moti-milo/smart-contract/node_modules/hardhat/src/internal/artifacts.ts:275:17) at Artifacts.readArtifact (/home/muskaan )/moti-milo/smart-contract/node_modules/hardhat/src/internal/artifacts.ts:58:26) at getContractFactory (/home/muskaan/moti-milo/smart-contract/node_modules/@nomiclabs/hardhat-ethers/src/internal/helpers.ts:99:22) at main (/home/muskaan/moti-milo/smart-contract/scripts/deploy.js:4:25) at /home/muskaan/moti-milo/smart-contract/scripts/deploy.js:31:9
请帮帮忙,我已经困了一段时间了。
这是我的deploy.js文件:
const { ethers } = require('hardhat')
const main = async() => {
const dogeFactory = await ethers.getContractFactory('Dogecoin')
const dogeContract = await dogeFactory.deploy()
await dogeContract.deployed()
console.log('Dogecoin deployed to:', dogeContract.address)
const bitcoinFactory = await ethers.getContractFactory('Btc')
const bitcoinContract = await bitcoinFactory.deploy()
await bitcoinContract.deployed()
console.log('Bitcoin deployed to:', bitcoinContract.address)
const solanaFactory = await ethers.getContractFactory('Solana')
const solanaContract = await solanaFactory.deploy()
await solanaContract.deployed()
console.log('Solana deployed to:', solanaContract.address)
const usdcFactory = await ethers.getContractFactory('Usdc')
const usdcContract = await usdcFactory.deploy()
await usdcContract.deployed()
console.log('USDC deployed to:', usdcContract.address)
}
;(async ()=>{
try{
await main()
process.exit(0)
} catch(error){
console.error(error)
process.exit(1)
}
})()我使用$ npx hardhat run scripts/deploy.js --network rinkeby部署
发布于 2022-08-19 03:58:50
由于您将合同命名为“Btc”,因此名称也应该在getContractFactory上同步。
在您的Dogecoin.sol上不要使用:
contract Btc is ERC20, Ownable { ...相反,请使用:
contract Dogecoin is ERC20, Ownable { ...然后,不要改变你的deploy.js。然后跑:
npx hardhat clean
npx hardhat deploy scripts/deploy.js --network rinkeby它应该能正常工作。
https://ethereum.stackexchange.com/questions/133907
复制相似问题