我正在使用此代码在我的合同中实现转发器。
contract Forward {
address public destinationAddress;
event LogForwarded(address indexed sender, uint amount);
event LogFlushed(address indexed sender, uint amount);
constructor() public {
destinationAddress = msg.sender;
}
function() payable public {
emit LogForwarded(msg.sender, msg.value);
destinationAddress.transfer(msg.value);
}
function flush() public {
emit LogFlushed(msg.sender, address(this).balance);
destinationAddress.transfer(address(this).balance);
}
}但是它显示了一些错误,因为我使用的是Compiler0.6.0,这段代码是0.4.23,我无法将它转换为最新版本。有人能帮我吗?
以下是错误的预览:

发布于 2020-11-18 20:54:34
把address public destinationAddress;改成address payable public destinationAddress;对我很有帮助。
https://ethereum.stackexchange.com/questions/90282
复制相似问题