[Ethereum] Solidity – How to send ETH from the wallet to another address

soliditywallet-transfer

I would like to programmatically send my ETH to another wallet address using Solidity.
Could you please tell me this is possile? If yes, please give me some examples.
I read the docs and it has only for created tokens.

Thanks

Best Answer

I would love to be wrong, but it is not yet possible to send ether from one wallet address to another wallet address using only Solidity.

But still, if you want you can write your contract with some method:

pragma solidity ^0.4.18;

contract Example {
    function sendEther(address _addr) public payable {
        _addr.transfer(msg.value);
    }
}

and then using this method send some ether to desired address:

await instance.sendEther.sendTransaction(accounts[1], { from: accounts[0], value: 10**18 });

But it is not convinient, when you can just use:

await web3.eth.sendTransaction({ from: accounts[0], to: accounts[1], value: 10**18 });
Related Topic