You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LESSON 7
wanted to add reading balance account by address before, and after withdraw() function. The balance after withdraw displays previous value. I need to rexecute the withdraw script to display it 0. How to make it work?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
LESSON 7
wanted to add reading balance account by address before, and after withdraw() function. The balance after withdraw displays previous value. I need to rexecute the withdraw script to display it 0. How to make it work?
`
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}
)const addressToAmountFunded = await fundMe.getAddressToAmountFunded(deployer)
console.log(
Address balance: ${addressToAmountFunded}
)console.log("Withdrawing from contract...")
const transactionResponse = await fundMe.withdraw()
await transactionResponse.wait(1)
console.log("Got it back!")
const addressToAmountFundedAfterWithdraw = await fundMe.getAddressToAmountFunded(deployer)
console.log(
Address balance: ${addressToAmountFunded}
)}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
`
Got contract FundMe at 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 Address balance: 123000000000000000 Withdrawing from contract... Got it back! Address balance: 123000000000000000
Beta Was this translation helpful? Give feedback.
All reactions