codedamn

Withdrawal Pattern

Created by Kshitij about a year ago

0

No description provided

12 Comments

    0

    This is really confusing

    @swethpavan0769

    Sweth Pavan

    @swethpavan0769

    0

    can't understand after watching it a third time

    @harman0370

    CHETAN HARMAN

    @harman0370

    0

    watched two times, but understood.

    @sarojvrc

    Saroj Behera

    @sarojvrc

    0

    Can you give an example on how an external contract can call a function in another contract?

    @mukeshraj0722

    Mukesh Raj

    @mukeshraj0722

    0

    Sir here even if we use investors[msg.sender]==msg.value, it is till not calling any function in demo right. So shouldn't the fallback function still be invoked?

    @harimenon0143

    Hari Menon

    @harimenon0143

    0

    It would be great if you have been deployed and tested this smart contract as this is quite complicated at first and would have also make better understanding

    @rocco

    ASHPREET SINGH ANAND

    @rocco

    0

    tl;dr of this video: make separate functions of send and withdrawal. also when fallback() function is called, it will revert only withdraw() function's actions (not the sendEther() function's actions) so it doesn't matter even withdraw() function got reverted because by that time we already got the amount of 12 eth (which is richest person) I hope it helps!

    @pintuprajapati

    Pintu Prajapati

    @pintuprajapati

    0

    Could you clarify how the control transfers to demo() from Withdrawlpattern() when the transfer is initiated either from sendEther() or withdraw() ?

    @rjarun8

    Raj Arun

    @rjarun8

    0

    I understood what you are trying to explain, I believe that if you add the receive() function to the demo contract, and you change the transfer() to call{}() in the Withdraw contract that'll solve the issue that the demo contract reverts the withdraws, otherwise the Ethers will be locked in the Withdraw contract, which is an issue, not a coding issue, but an issue with the logic

    1

    i was expecting to use 'new' keyword

    @chaitanya22

    Chaitanya Patil

    @chaitanya22

    1

    As per I understood now our contract will save the state of who is the richest, but how will they get their ethers back as withdraw function will be reverted, so will their ethers will stuck in contract. Could you please explain this concept again.

    @stark09

    Prabal Gupta

    @stark09

    0

    but when fallback function will be called as the line investors[msg.sender]=0 will be reverted back , wont it be a glitch and contract can call withdraw function infinite times and balance didnt updated to zero ?

    @ad999s

    Aditya Kotwal

    @ad999s

Your comment