Working on this Udemy course for Ethereum and i keep getting the error mentioned in the title of the question.
For reference i have checked out the answers on questions: 1, 2 and 3. But the error persists.
The contract goes like this:
pragma solidity >=0.4.22 <0.6.0;
contract Lottery {
address public manager;
address[] public players;
constructor() public {
manager = msg.sender;
}
function enter() public payable {
require(msg.value > .01 ether);
players.push(msg.sender);
}
function random() private view returns (uint) {
return uint(keccak256(abi.encodePacked(msg.sender, now, players)));
}
function pickWinner() public {
uint index = random() % players.length;
players[index].transfer(address(this).balance); // Where the error happens
}
}
Using Remix Solidity compiler.
I am pretty sure this is some old version code error since the Solidity version used in the course is ^0.4. Can anyone guide me what am I missing here?