类型地址不是隐式转换为预期类型地址应付的
我正在使用Cryptozombies Solidity教程,并且有一个问题:
Type address is not implicitly convertible to expected type address payable.
这是代码:
function withdraw() external onlyOwner {
address payable _owner = address(uint160(owner()));
_owner.transfer(address(this).balance);
}
我使用VSCODE和固体扩展。 IDE以红色突出显示这一行:
address payable _owner = address(uint160(owner()));
并显示上述错误。我应该怎么做才能避免此错误?
I am taking CryptoZombies Solidity tutorial and I have got such a problem:
Type address is not implicitly convertible to expected type address payable.
Here is the code:
function withdraw() external onlyOwner {
address payable _owner = address(uint160(owner()));
_owner.transfer(address(this).balance);
}
I use VSCode and a Solidity extension. The IDE highlights this line in red:
address payable _owner = address(uint160(owner()));
and displays the above error. What should I do to avoid this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
付款()
Typecast函数将地址>地址>的类型更改为
地址应付
。You can use the
payable()
typecast function to change the type of anaddress
toaddress payable
.