I am trying to write a smart contract that will send eth from one account to another account :

Contract Send {

 event Sent(address from, address to, uint amount );

 function send(address _receiver, uint _amount) public payable{
    emit Sent(msg.sender, _receiver, _amount);

Here, the amount is deducted from the sender's account but not being added to receivers account. I want to use transfer() function for this.

Thanks in advance!

  • by sender you mean the contract? The ether will be taken from the contract. So the sender should send an amount of ether equal to amount when calling the function send, or the contract should have amount ethers
    – Jaime
    Nov 1, 2018 at 10:38

1 Answer 1


This contract works and there is no need to change it.

The user interacting with this contract must send Ether in the transaction in order to trigger a transfer to the _receiver. The Ether gets sent to the contract, and lives there prior to transfer from the contract to the _receiver.

I would suggest removing _amount and simply using msg.value to send the entire value that is sent in the transaction.

Additionally, this can be done with a simple transaction and does not decessarily need a smart contract.

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.