I am getting false Transaction mined but execution failed error from the constructor function in the contract. I am just saving the address from which the contract is deployed in manager variable and not sending any money to the account.
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
contract Lottery{
address public manager;
address[] public players;
constructor() public {
manager = msg.sender;
}
function enter()public payable{
require(msg.value > 0.1 ether);
players.push(msg.sender);
}
//Random number generator function.
function random()private view returns (uint){
return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, players)));
}
function pickWinner()public{
uint index = random() % players.length;
address contractAddress = address(this);
payable(players[index]).transfer(contractAddress.balance);
}
}
After solidity v0.7, it says that visibility of the constructor is not required, so i tried by removing the public
visibility. I also tried with payable
visibility to the constructor()
but still getting the same error.