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);


function random() private view returns(uint){
  return uint(keccak256(block.difficulty, now, players));

function pickWinner() public {
    uint index = random() % players.length;

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.
    – user19510
    Aug 30, 2018 at 15:37

1 Answer 1


It works just fine here in Remix.

Did you perhaps forget to change the unit in Remix? The default unit is wei - change it to Ether.

EDIT After rereading the original post:

The error message hints that you may be trying to send Ether when deploying the contract. You can't do that - you have to first deploy it and after that call the deployed contract's enter function. So in Remix:

1) Go to "Run" tab

2) Press the red "Deploy" button

3) Change units in top right to 'ether' and input '1' in the box

4) Open the contract in the "Deployed contracts" section. Click the red 'enter' function and check the console. Should succeed.

  • yes I change the unit to ether but still get the same error Aug 30, 2018 at 9:55
  • 1
    FYI, "Note: The constructor should be payable if you send value" shows up any time a transaction reverts in Remix. It's usually a red herring. :-)
    – user19510
    Aug 30, 2018 at 15:36
  • I'll add that I also tested the code in the original post in Remix, and it works fine for me too.
    – user19510
    Aug 30, 2018 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.