0

maybe also how to develop a small application with the wanted functionality.....

I hope someone give me useful answer. Thanks

marked as duplicate by Eli Drion, mirg, Lauri Peltonen, ivicaa, Ismael Apr 3 '18 at 15:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Something like this:

// resend all sent ether. Or maybe some part of it?
function sendEther(address _to) public payable {
     _to.transfer(msg.value);
 }

 mapping (address => uint256) public balances;

 // Send tokens in exchange of Ether
 function sendTokens(address _to) public payable {
     uint divider = 10;
     uint _value = msg.value / divider;
     balances[msg.sender] -= _value;
     balances[_to] += _value;
 }
}

The actual logic of how much Ether to send and how many tokens to send is up to you. And the code is missing a lot of security checks, but you get the idea.

Also, as already pointed out in another answer, you should consider using the fallback function if you want to make sure incoming Ether gets processed.

0

If you want to send ETH automatically, you want to use fallback function

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