-
When I run: It runs successfully. When running the command: it returns: const { ethers, getNamedAccounts } = require("hardhat")
async function main() {
const { deployer } = await getNamedAccounts()
const fundMe = await ethers.getContract("FundMe", deployer)
console.log(`Got contract FundMe at ${fundMe.address}`)
console.log("Funding contract...")
const transactionResponse = await fundMe.fund({
value: ethers.utils.parseEther("0.1"),
})
await transactionResponse.wait()
console.log("Funded!")
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
}) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
Can you send a snippet of your contract code? You are trying to send less ETH than required in your constructor |
Beta Was this translation helpful? Give feedback.
-
Maybe not specifying the waiting time make it out of gas. You can check it and let me know. - await transactionResponse.wait()
+ await transactionResponse.wait(1) If you still face issues then show both your contracts. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
There was an issue in my 00-deploy-mocks.js It looks like the
may have fixed the issue. ORIGINAL: const { network } = require("hardhat")
const {
developmentChains,
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
if (developmentChains.includes(network.name)) {
log("Local network detected...deploying mocks")
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_ANSWER],
})
log("Mocks deployed!")
log("_________")
}
}
module.exports.tags = ["all", "mocks"] NEW: const { network } = require("hardhat")
const DECIMALS = "8"
const INITIAL_PRICE = "200000000000" // 2000
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
// If we are on a local development network, we need to deploy mocks!
if (chainId == 31337) {
log("Local network detected! Deploying mocks...")
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_PRICE],
})
log("Mocks Deployed!")
log("------------------------------------------------")
log(
"You are deploying to a local network, you'll need a local network running to interact"
)
log(
"Please run `npx hardhat console` to interact with the deployed smart contracts!"
)
log("------------------------------------------------")
}
}
module.exports.tags = ["all", "mocks"] |
Beta Was this translation helpful? Give feedback.
There was an issue in my 00-deploy-mocks.js
It looks like the
may have fixed the issue.
ORIGINAL: