Closed oblakov0372 closed 10 months ago
Thanks for this!
Can you:
Bro, have you solved it. My problem is the same as yours, and can't be solved.
i spent hours on this but i fixed it at last
replace the
const transactionReceipt = await transactionResponse.wait();
const { gasUsed, effectiveGasPrice } = transactionReceipt;
const withdrawGasCost = gasUsed.mul(effectiveGasPrice);
with
const gasCost = async (txHash, toNative = true) => {
const transactionResponse = await fundMe.withdraw()
const transactionReceipt = await transactionResponse.wait(1)
const { gasUsed, effectiveGasPrice } = await transactionReceipt(
[txHash]
)
const gasCost = BigInt(gasUsed) * BigInt(effectiveGasPrice)
it should work . And thanks again PatrickAlphaC for the good work
Bro, have you solved it. My problem is the same as yours, and can't be solved.
i spent hours on this but i fixed it at last
replace the
const transactionReceipt = await transactionResponse.wait();
const { gasUsed, effectiveGasPrice } = transactionReceipt;
const withdrawGasCost = gasUsed.mul(effectiveGasPrice);
with
const gasCost = async (txHash, toNative = true) => {
const transactionResponse = await fundMe.withdraw()
const transactionReceipt = await transactionResponse.wait(1)
const { gasUsed, effectiveGasPrice } = await transactionReceipt(
[txHash]
)
const gasCost = BigInt(gasUsed) * BigInt(effectiveGasPrice)
it should work . And thanks again PatrickAlphaC for the good work
yarn hardhat test --grep "withdraw" yarn run v1.22.21 warning package.json: No license field $ D:\Developing_WEB3\HardhatFundMe\node_modules.bin\hardhat test --grep withdraw
Fund me withdraw
0 passing (2s) 2 failing
1) Fund me withdraw withdraws ETH from a single funder: TypeError: Cannot read properties of undefined (reading 'getBalance') at Context. (test\unit\FundeMe.test.js:45:59)
2) Fund me withdraw is allows us to withdraw with multiple funders: TypeError: Cannot read properties of undefined (reading 'getBalance') at Context. (test\unit\FundeMe.test.js:80:59)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
describe("withdraw", function () { beforeEach(async () => { await fundMe.fund({ value: sendValue }); }); it("withdraws ETH from a single funder", async () => { // Arrange const startingFundMeBalance = await fundMe.provider.getBalance( fundMe.address ); const startingDeployerBalance = await fundMe.provider.getBalance( deployer );