0

When a contract transfers ether to an address, who pays the gas?

For example:

function withdrawRefund(){
    uint refund = refunds[msg.sender];
    refunds[msg.sender] = 0;

    msg.sender.transfer(refund);
}

The sender pays the gas for the contract state change. But who pays the gas for the ether transfer, the sender or the contract?

1

All the fees of a transaction (including the internal transactions it triggers) is paid by the transaction sender.

  • 1
    @aasafmo. Meaning, the gas is paid by the individual claiming the refund. – Rob Hitchens - B9lab Jul 1 '17 at 0:48
  • Thanks! So is there any scenario that the contract pays gas? because always the sender is not the contact. – assafmo Jul 1 '17 at 7:22
  • 1
    @assafmo that is being discussed here. However, the answer is no, currently it's not possible. – jeff Jul 1 '17 at 7:34

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.