Lesson 7: TransactionExecutionError: Transaction ran out of gas #5241
-
OverviewI am trying to test my FundMeWithLibrary
withdraw
1) Withdraws ETH from the contract
0 passing (670ms)
1 failing
1) FundMeWithLibrary
withdraw
Withdraws ETH from the contract:
TransactionExecutionError: Transaction ran out of gas My repository: https://github.com/Jatinkkalra/hardhat-fund-me As far as I know, a local node/mock nodes are being used for the gas fees. yarn hardhat node I am still facing this issue though. Please let me know if I am doing something wrong. 🙏 |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Apr 6, 2023
Replies: 1 comment 1 reply
-
@Jatinkkalra Your loop inside withdraw function is running inappropriate way which makes the program consume a lot of gas. Fix it; for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex = funderIndex++ /*ie funderIndex + 1*/
) here |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Jatinkkalra
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Jatinkkalra Your loop inside withdraw function is running inappropriate way which makes the program consume a lot of gas. Fix it;
here
funderIndex = funderIndex++
should befunderIndex++