-
// fund function
async function fund() {
const ethAmount = "77"
console.log(`Funding with ${ethAmount}...`)
if (typeof window.ethereum !== "undefined") {
const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, abi, signer)
const transactionResponse = await contract.fund({
value: ethers.utils.parseEther(ethAmount),
})
}
} During lesson 8, at around 13:17:46, when the fund function is called from the Fund Me App via browser, I am faced with the error below after clicking confirm.
To provide some context, I trashed the terminal after sending through a few transactions as I was facing a separate error prompting that I was not sending enough ETH. After executing "yarn hardhat node" again, confirming the fund transaction via metamask results in the error above. By importing a new test account to my metamask (using Account 1 on the hardhat localhost network instead of Account 0), I was able to successfully confirm the fund transaction with no errors. However, switching back to Account 0 results in the same error happening again. Would anyone know what is causing the nonce to be 4 instead of 2 and how would I go about fixing the above error? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Beta Was this translation helpful? Give feedback.
-
This error happens when you use Metamask with a local blockchain such as Hardhat node.
So instead of |
Beta Was this translation helpful? Give feedback.
Click onto your metamask account avatar -> Setting -> Advanced -> Reset Account
It happens when you restart your local hardhat node. Metamask doesn't know you've restarted it and still has the nonce of whatever it was on your previous node run.