I have below contract. I deploy my contract in remix and put 1 ether in value but when I execute enter()
function I get an error.
This is the contract:
pragma solidity ^0.4.17;
contract Lottery{
address public manager;
address[] public players;
constructor() public payable{
manager = msg.sender;
}
function enter() public payable {
require(msg.value > 0.01 ether);
players.push(msg.sender);
}
function random() private view returns(uint){
return uint(keccak256(block.difficulty, now, players));
}
function pickWinner() public {
uint index = random() % players.length;
players[index].transfer(this.balance);
}
}
This is the Error message:
from:0xca3...a733c to:Lottery.enter() 0xb87...69cfa value:0 wei data:0xe97...dcb62 logs:0 hash:0x1a5...811a1
transact to Lottery.enter errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value. Debug the transaction to get more information.
value:0 wei
looks like the problem. You may want to describe more specifically how you're sending the transaction and specifying that 1 ether should be attached, because it doesn't look like that's working.