-1

how to add withdraw function to get smart contract ether to my wallet

https://github.com/rohitsahu21/Token-Sale

0

This should work:

function withdraw() public {
    admin.transfer(address(this).balance);
}

The only address that will receive the ether is the admin, but anyone can execute the function (still the ether goes to the admin). To be sure that only you can execute it, you can do:

function withdraw() public {
    require(msg.sender == admin);
    admin.transfer(address(this).balance);
}

Hope this helps.

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.