我使用了以下代码,我认为该代码将能够提取出任何已存入智能合约的以太币。您能帮忙解释一下为什么这可能行不通吗?
function withdraw() public {
require(owner == msg.sender);
msg.sender.transfer(address(this).balance);
}
我在提取以太币时遇到问题,并且想知道代码的哪一部分阻止了我这样做。
答案 0 :(得分:0)
function withdraw(uint amount) public payable{
require(address(this).balance >= amount);
msg.sender.transfer(amount);
}
使用此代码