Reputation: 39
I'm getting this error in Solidity for the following code snippet:
member balance not found or not visible after argument-dependent lookup in contract
function pickWinner() public {
uint index = random() % players.length;
players[index].transfer(address(this).balance); // error here
}
What's the problem?
Upvotes: 0
Views: 614
Reputation:
Is your players array payable? Your code works for me:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract PickWinner {
address payable[] players;
function pickWinner() public {
uint256 winnerIndex = 80 % players.length; // I chose 80 as a "random" value
players[winnerIndex].transfer(address(this).balance);
}
}
Upvotes: 1