0
pragma solidity ^0.8.1;

contract SendMoney{
    uint public publicBalance;
    uint public lockedUntil;

    function receiveMoney() public payable{
        publicBalance += msg.value;
        lockedUntil = block.timestamp + 1;
    }

    function getBalance() public view returns(uint){
        return address(this).balance;
    }

    function withdrawMoney() public{
        if(lockedUntil < block.timestamp){
            address payable to  = payable(msg.sender);
            to.transfer(getBalance());
        }
    }

    function withdrawMoneyTo(address payable _to) public{
        if(lockedUntil < block.timestamp){
            _to.transfer(getBalance());
        }
    }
}

I have deployed a smart contract with some address lets say. I sent some ether to the smart contract with the method receive money. Now, when i press on withdrawMoney() function with some another address. Who will pay the gas fee? is it the address that has deployed the smart contract? or is it the smart contract itself?

3

1 Answer 1

0

The gas fee for any smart contract interaction is paid by the EOA (Externally Owned Account) that calls it. Even if the smart contract makes another transaction (as an internal transaction), it's considered to be part of the original transaction called by the EOA, so the EOA will have to pay the gas for the entire transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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