使用版本0.6.0
pragma solidity ^0.6.0;
contract Test {
function sendValue(address payable recipient, uint256 amount) external {
(bool success, ) = recipient.call{ value: amount }("");
}
}
Test.sol:5:42:ParserError:预期为“;”但得到 '{' (bool success, ) =recipient.call{ value: amount }(""); ^
为什么会出现这个错误?
您正在使用 Solidity 0.7 中引入的语法,但在 0.6 中尚未有效。
对于 0.6,请使用:
(bool success, ) = recipient.call.value(amount)("");
来源和更多信息:
- 0.7 语法:https://docs.soliditylang.org/en/v0.7.0/control-structs.html#external-function-calls https://docs.soliditylang.org/en/v0.7.0/control-structures.html#external-function-calls
- 0.6 语法:https://docs.soliditylang.org/en/v0.6.0/control-structs.html#external-function-calls https://docs.soliditylang.org/en/v0.6.0/control-structures.html#external-function-calls
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)