简体   繁体   English

Solidity 0.8.0 中的 ParserError

[英]ParserError in Solidity 0.8.0

hello Guys !大家好 !

i'm trying to create a Dapp contracts it works perfectly in 0.4.2 but giving me errors in 我正在尝试创建一个 Dapp 合约,它在 0.4.2 中完美运行,但给了我错误

latest Sol compiler version.最新的 Sol 编译器版本。

 pragma solidity >=0.7.0 <0.8.0; function endSale() public { require(msg.sender == admin); require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this)) )); admin.transfer( address payable(this).balance) } }

ERROR错误

在此处输入图像描述

Payable should be the recipient , not the sender address. Payable 应该是收件人,而不是发件人地址。 Also, your syntax is slightly incorrect.此外,您的语法略有不正确。

Assuming admin is saved as address (not payable)假设admin保存为address (不支付)

payable(admin).transfer(address(this).balance);

And if admin is already address payable , it's enough to call just this如果admin已经是address payable ,那么调用这个就足够了

admin.transfer(address(this).balance);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM