0

Let's say you have a payable function that immediately sends the payable amount to another account.

It is possible for this function to be hacked? Or no? If the contract never ends up storing funds aside from that single function call, wherein it is immediately transferred to someone else.

1 Answer 1

0

if you are transferring the msg.value without storing it,even if if a hacker tries to call the payable function the moment they received the ether, they will receive the ether they sent to the payable function and won't receive any new ether.

2
  • Ok, got it. So it's basically impossible, unless there is an error in the sending of the ether, but you could easily get around this by making the calls required, right? What would happen to the ether if the call didn't go through?
    – antioi
    Oct 19, 2021 at 5:44
  • if the call did not go through or error happens, the state change during the function call will be reverted back to its original state or the previous state before the function call, hence the contract won't receive the ether, it will stay with the user or won't be deducted from the user.
    – leycun
    Oct 19, 2021 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.