预期的标识符但已“应付”

时间:2019-02-23 14:20:11

标签: blockchain ether

以下是我的代码:

    pragma solidity >=0.4.17;

contract Lottery {
    address public manager;
    address payable [] public players;

    constructor () public {
        manager = msg.sender;
    }

    function enter() public payable {
        require(msg.value > 0.01 ether);
        players.push(msg.sender);
    }

    function random() private view returns (uint) {
        return uint256(keccak256(abi.encodePacked(block.difficulty, now, players)));
    }

    function pickWinner() public restricted {
        require(msg.sender == manager);
        uint256 index = random() % players.length;
        players[index].transfer(address(this).balance);
        players.length = 0;
    }

    modifier restricted() {
        require(msg.sender == manager);
        _;
    }

}

此代码在Remix编辑器中正常工作。 但是在VS代码中出现错误如下:

期望的标识符但已“应付”

1 个答案:

答案 0 :(得分:0)

我怀疑您正在运行不同版本的Solidity编译器。

https://solidity.readthedocs.io/en/v0.5.3/一样,当前的Solidity版本为0.5.3