Skip to content
Verified contractPartial

Lottery

Address0xb72ced50dcd6c8a146a4f009f323151087f86e3b
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.1.3

 

Same code

Only this contract

 

Details

Compiler
solc 0.1.3+commit.028f561d
Language
solidity
Optimization
Yes, 200 runs
License
Not stated
Match
Partialcreation code: no, runtime code: yes
Verified on Sourcify
Created in block
54,564
Creation transaction
0xb27e4512d7…c7d23ddaf9

Lottery.sol

// Recovered by EthereumHistory (ethereumhistory.com) -sw
contract Lottery {
    uint lastBlock;
    uint balance;
    address[] tickets;
    uint64[] secrets;
    mapping (address => bytes32) secretHash;
    mapping (address => uint) balances;

    function Lottery() {
        lastBlock = block.number;
    }

    function buyTicket(bytes32 hash) {
        if (block.number % 88 < 40) {
            secretHash[msg.sender] = hash;
            balances[msg.sender] += msg.value;
            balance += msg.value;
        }
    }

    function random() returns (uint64) {
        uint64 seed = 0;
        for (uint i = 0; i < secrets.length; i++) {
            seed = seed ^ secrets[i];
        }
        uint64 x = seed;
        while (x > tickets.length) {
            if (x & 2^16 - 1 < tickets.length) return x % 0xffff;
            if (x > 0x10000) x = x / 0x10000;
            else return x % uint16(tickets.length);
        }
    }

    function submitSecret(uint64 secret) {
        uint32 i;
        if (block.number % 88 < 68 && block.number % 88 > 48) {
            if (sha3(secret) == secretHash[msg.sender]) {
                secrets[secrets.length] = secret;
            }
        }
    }

    function payoutReady() returns (bool) {
        return block.number % 88 > 68 && block.number - lastBlock > 68;
    }

    function payout() returns (address) {
        address winner;
        if (payoutReady()) {
            winner = tickets[random()];
            winner.send(balance - 25000 * tx.gasprice);
            lastBlock = block.number;
            delete tickets;
            delete secrets;
            balance = 0;
            for (uint i = 0; i < tickets.length; i++) {
                delete secretHash[tickets[i]];
                delete balances[tickets[i]];
            }
            return winner;
        }
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.