A withdraw function for Token Sale
I was trying my hand on the Capture the Ether Levels. And was thinking there should be a withdrawal function that allows withdrawal of excess balance, as the remaining ether, after the level is finished, is locked in that contract forever. I know it is testnet eth, but still.
A simple implementation could be like the below:
function withdraw() public {
require(isComplete(), "The level is still not solved");
msg.sender.transfer(address(this).balance);
}
Anyone can call the above function, so that might be a potential vulnerability ;) But still better than those tokens being locked.
Posted Jul 4, 2022, 11:12 AM UTC
12
It's not that rare even on mainnet, when you find _real_ Eth and especially tokens locked up forever.
Sad reality.