Lesson7: ERROR TransactionExecutionError: Transaction ran out of gas #2487
-
I am stuck at local testing. when i try to test the withdraw function it shows following error.
describe("withdraw", async function() {
beforeEach(async function() {
await fundMe.fund({ value: sendValue })
})
it("withdraw eth from a single funder", async () => {
// Arrange
const startingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const startingDeployerBalance = await fundMe.provider.getBalance(
deployer
)
// Act
const transactionResponse = await fundMe.withdraw()
const transactionReceipt = await transactionResponse.wait()
const { gasUsed, effectiveGasPrice } = transactionReceipt
const gasCost = gasUsed.mul(effectiveGasPrice)
const endingFundMeBalance = await fundMe.provider.getBalance(
fundMe.address
)
const endingDeployerBalance = await fundMe.provider.getBalance(
deployer
)
// Assert
// Maybe clean up to understand the testing
assert.equal(endingFundMeBalance, 0)
assert.equal(
startingFundMeBalance.add(startingDeployerBalance).toString(),
endingDeployerBalance.add(gasCost).toString()
)
})
}) i even copied patrick's code, but it doesn't work. here is the github repo link of the project: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
@udayg24 Try to add gas manually like this: rinkeby: {
url: process.env.RPC_URL,
accounts: [process.env.PRIVATE_KEY],
chainId: 4,
blockConfirmations: 6,
gas: 6000000,
}, |
Beta Was this translation helpful? Give feedback.
-
Hey @udayg24 are you running this on a testnet or locally on hardhat network? |
Beta Was this translation helpful? Give feedback.
-
Try again after @alymurtazamemon 's changes, and let us know if it persists. :) |
Beta Was this translation helpful? Give feedback.
@udayg24 Try to add gas manually like this: