确定性,成员"转移"在参数依赖后未找到或不可见

Tor*_*rof 3 ethereum solidity smartcontracts

使用Solidity ^ 0.5.0,我实际上是在尝试实现在^ 0.4.17中使用的旧代码,但它在Remix上引发了错误.我检查了语法和一切,但只是无法捕捉到什么是错的.任何帮助高度赞赏.

pragma solidity ^0.5.0;

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

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

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

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

  function pickWinner() public {
    uint index = pseudoRandom() % players.length;
    players[index].transfer(address(this).balance);
  }
}
Run Code Online (Sandbox Code Playgroud)

这是错误消息:

browser/Lottery.sol:22:8:TypeError:在地址中依赖于参数的查找后,未找到或未显示成员"transfer".

玩家[指数] .transfer(地址(msg.sender).balance);

^ ^ ---------------------

fob*_*oba 5

请参阅Solidity v0.5.0 Breaking Changes.

正如这里指出的:

地址类型分为地址和地址,其中只有地址应付提供转移功能.

见我的答案在这里了解更多详情.

改变这一行:

address[] public players;
Run Code Online (Sandbox Code Playgroud)

对此:

address payable[] public players;
Run Code Online (Sandbox Code Playgroud)

编辑

谢谢smarx!