Search code examples
ethereumsoliditytruffle

Solidity payable function payout


Maybe I didn't understand the concept of the payable function...

So I have function like this:

function fundEthereum () payable { }

Now as I understood this, Ethers are sent to this function and stored inside of the contract.

What I now want to do is, when someone sends ether to this function, send these ether furter to another account / address.

The question is how can I send these ethers further to another address?

Thanks for the help

Wish you a merry christmas


Solution

  • You have correctly understood. I think what you want to send is the total ammount of ether sended in the function, you can found them in the msg.value . You need the receiver address, then you can send him the amount transaction with the send function.

      function send(address _receiverAddress) payable {
        _receiverAddress.send(msg.value);
      };