Lesson 4 - FundMe.sol #2675
-
Can anyone explain what is the need to reset the funders array and addressToAmountFunded mapping to 0 ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
@kunsane It is not mandatory to reset these, Patrick just did so so that after every withdrawal we can know the new funders and how much they funded after each withdrawal. |
Beta Was this translation helpful? Give feedback.
-
function withdraw() public onlyOwner {
for (uint256 funderIndex=0; funderIndex < funders.length; funderIndex++){
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0); Setting this mapping As for the |
Beta Was this translation helpful? Give feedback.
@kunsane It is not mandatory to reset these, Patrick just did so so that after every withdrawal we can know the new funders and how much they funded after each withdrawal.