Очень очень новичок в этом.
Вы отправляете 1 эфир на контракт:
Почему контракт не исполняется?
Спасибо
pragma solidity ^0.4.11;
contract BasicLottery {
// A mapping to store ethereum addresses
mapping(uint => address) public gamblers;
uint public my_length; //*to keep track of the length.
uint public random; //random number
function BasicLottery(){
my_length == 0;
}
// function when someone sends an ether
// stores the address, and if there are 5 participants,
// chooses a winner and gives the money
function bet() payable {
// If the bet is not 1 ether, send the
// money back.
require(msg.value == 1);
my_length +=1;
gamblers[my_length] = msg.sender;
if (my_length == 5) {
// pick a random number between 1 and 5
random = uint(block.blockhash(block.number-1))%5 + 1;
gamblers[random].transfer(5);
my_length == 0;
}
}
}
msg.value == 1
означает, что 1 вэй отправлен. Вам нужно заменить его на msg.value == 1 ether
.
Ошибка отсутствия газа, вероятно, является результатом неправильного require()
, учитывая, что вы подаете разумное количество газа.
Также вам нужно изменить my_length == 0;
наmy_length = 0;