Skip to content

Instantly share code, notes, and snippets.

@wizardofzos
Last active March 12, 2018 17:27
Show Gist options
  • Save wizardofzos/65bd828c1c339995c1689fb22084af40 to your computer and use it in GitHub Desktop.
Save wizardofzos/65bd828c1c339995c1689fb22084af40 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.18;
// send 0.001 ETH to 0x9aabaa0a378fce98c05d17f130223df7475eec23 (Contract interface at the URL)
// Get a 10% chance of winning 0.008 (the house get 0.002 fer it's trouble...) after the 10th player deposits
// then it starts over again...
// Can use the ABI(interface) at https://etherscan.io/address/0x9aabaa0a378fce98c05d17f130223df7475eec23
contract Quicketh {
// Bet 0.001 ETH.
// Get a 10% change to win 0.008
address public owner; // Who's the boss?
uint public players; // How many are playing?
address[] public playedWallets; // These can win
address[] public winners; // These have won
uint playPrice = 0.001 * 1000000000000000000; // 0.001 ETH
uint public rounds; // How long have we been going?
event WinnerWinnerChickenDinner(address winner, uint amount);
event AnotherPlayer(address player);
function Quicketh() public payable{
owner = msg.sender;
players = 0;
rounds = 0;
}
function play() payable public{
require (msg.value == playPrice);
playedWallets.push(msg.sender);
players += 1;
AnotherPlayer(msg.sender);
if (players > 9){
uint random_number = uint(block.blockhash(block.number-1))%10 + 1; // Get random winner
winners.push(playedWallets[random_number]); // Add to winner list
playedWallets[random_number].transfer(8*playPrice); // Send price to winner
WinnerWinnerChickenDinner(playedWallets[random_number], 8*playPrice); // Notify the world
owner.transfer(this.balance); // Let's get the profits :)
rounds += 1; // See how long we've been going
players = 0; // reset players
delete playedWallets; // get rid of the player addresses
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment