I created a contract with a payable function but the ether is stored in the contract I am looking for a way to transfer the ether to another address

4 Answers 4


If the ether is already in the contract and you do not have the functionality to transfer ether already implemented in it, the ether will be forever in the contract.

A simple contract that receives ether and allows for transferring is shown below. Only the person that deploys the contract will be able to transfer the ether.

pragma solidity ^0.4.24; 

contract myContract{

    address public owner;

    constructor() public {
        owner = msg.sender;

    function transfer(address to, uint256 amount) public {

    function () public payable {}

Hope this helps


You can call the receiver.transfer(amount) to send the ether in the receivers account


This is how I solve it:

function sendMoney(address to, uint value) public {
   address payable receiver = payable(to);

You must have a function in the contract that send ether out of the contract as well. This function does not have to be payable, but would look something like:


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.