2

I've been playing with Token contracts, so far so good, however once the Ether is sent and the tokens created, what happens to the Ether?

I have some Ether on the contract address, how do I withdraw it?

I guess it's not about the contract code but about the interface, I've been using Ethereum Wallet. The send funds screen only allows to fund the contract, not send from it.

  • 1
    The contract has to have an explicit method to make a transfers to an address. Another possibility is if the contract has a selfdestruct option. If the contract has none of this then I'm afraid the ether is stuck within it. – Ismael Sep 2 '17 at 17:34
4

The function would be something like this:

function withdraw() {
    msg.sender.transfer(this.balance);
}

Just make sure you only allow yourself to access it

  • Indeed, adding require ( msg.sender == owner ); before the transfer was all it took. Thank you. – Nicolas Bernard Sep 5 '17 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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