Closed michaelclubman515 closed 1 year ago
Also when I run "yarn hardhat deploy --tags mocks",It seems didn't deploy the mockV3Aggregator
terminal 's information like this
yarn run v1.22.19 warning ../package.json: No license field $ /Users/liwei/hardhat-fund-me/node_modules/.bin/hardhat deploy --tags mocks Nothing to compile ✨ Done in 2.34s.
Hey there. Having the same issues here. Hoping that someone can help.
When I use the command line like
yarn hardhat console
It works well.
but when I use the command line
yarn hardhat deploy --tags mocks.
some question pops up like this.
An unexpected error occurred:
cannot get the transaction for MockV3Aggregator's previous deployment, please check your node synced status
Hoping someone can help
resolve this by delete the deployments's files, it works well
just the line
npx hardhat deploy --tags mocks.
or
yarn hardhat deploy --tags mocks
just fixed in script 00-deploy-mock.js
when identify the network should be "network.name" not "chainId.name",cause in config file describe by network.name
if (developmentChains.includes(network.name)) {
Managed to fix too. Seems like mine was caused by a simple typo.
Should be
module.exports.tags = ["all", "mocks"];
Instead of
module.exports.tag = ["all, mocks"];
Notice the "tags" vs "tag" and the quotations on all, mocks.
At the section hardhat fundme / Mocking / tags in hardhat I typed yarn hardhat deploy --tags mocks the terminal give me message like under , no message about the deploying mocks, I think maybe something wrong with config
yarn run v1.22.19 warning ../package.json: No license field $ /Users/liwei/hardhat-fund-me/node_modules/.bin/hardhat deploy --tags mocks Nothing to compile ✨ Done in 1.69s.
hadhat-config.js `require("@nomicfoundation/hardhat-toolbox") require("hardhat-deploy") require("dotenv").config() const GOERLI_RPC_URL = process.env.GOERLI_RPC_URL const PRIVATE_KEY = process.env.PRIVATE_KEY module.exports = { // solidity: "0.8.17", solidity: { compilers: [{ version: "0.8.8" }, { version: "0.6.6" }], }, defaultNetwork: "hardhat", networks: { hardhat: { chainId: 31337, // gasPrice: 130000000000, }, goerli: { url: GOERLI_RPC_URL, accounts: [PRIVATE_KEY], chainId: 5, blockConfirmations: 6, }, },
} `
helper-hardhat-config.js
`const networkConfig = { 31337: { name: "localhost", },
} // 声明develomentChains
const developmentChains = ["localhost", "hardhat"] // export config可以让其他文件来交互 module.exports = { networkConfig, developmentChains, } `
00--deploy-mock.js
`const { network } = require("hardhat") const { developmentChains } = require("../helper-hardhat-config")
//声明chainId,MockV3Aggregator的构造函数参数
const DECIMALS = "8" const INITIAL_PRICE = "200000000"
module.exports = async ({ getNamedAccounts, deployments }) => { //console.log(
chainId is ${chainId}
) const { deploy, log } = deployments // The deployments field itself contains the deploy function.字段本身包含部署功能。 const { deployer } = await getNamedAccounts() // Fetch the accounts.获取账户 These can be configured in hardhat.config.ts as explained above. const chainId = network.config.chainId} // 如何只部署deploy mock文件 module.exports.tags = ["all", "mocks"] `