0

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

I hope someone give me useful answer. Thanks

0

2 Answers 2

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.