Reputation: 1
I used the following code which I thought would be able to withdraw any ether that was deposited to the smart contract. Can you help explain why this might not work?
function withdraw() public {
require(owner == msg.sender);
msg.sender.transfer(address(this).balance);
}
I am having issues withdrawing the ether and was wondering which part of the code is preventing me from doing so.
Upvotes: 0
Views: 598
Reputation: 63
function withdraw(uint amount) public payable{
require(address(this).balance >= amount);
msg.sender.transfer(amount);
}
use this code
Upvotes: 1