Skip to content

FundMe/Withdraw for each individual funder. #187

Answered by KMean
rileymross asked this question in Q&A
Discussion options

You must be logged in to vote

Maybe you can define a function that does that:

 function funderWithdraw() public payable{
        for(uint256 funderIndex = 0; funderIndex < funders.length; funderIndex++){
            if (funders[funderIndex] == msg.sender){
                uint256 amount = addressToAmountFunded[msg.sender];
                (bool callSucces,) = payable(msg.sender).call{value: amount}("");
                require(callSucces, "Call Failed!");
            }
        }
 }

Without Loop:

    function funderWithdraw() public payable{
        uint256 amount = addressToAmountFunded[msg.sender];
        if(amount > 0){
            (bool callSucces,) = payable(msg.sender).call{value: amount}("");
            require(…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PatrickAlphaC
Comment options

Answer selected by PatrickAlphaC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants