这是我的代码:
pragma solidity ^0.8.0;
contract sendMoney {
uint public balanceRecieved;
function recieveMoney()public payable {
balanceRecieved += msg.value;
}
function getBalance() public view returns(uint) {
return address(this).balance;
}
function withdrawMoney() public {
to payable(msg.sender) = address;
to.transfer(this.getBalance());
}
}
这是我得到的错误:
ParserError: Expected ';' but got 'payable' --> browser/sendMoney.sol:16:12: | 16 | to payable(msg.sender) = address; | ^^^^^^^
答案 0 :(得分:0)
您在这一行的语法不正确:
to payable(msg.sender) = address;
正确的语法:
address payable to = payable(msg.sender);