-
-
Save rfikki/14e445c0469543b359709f60fba484c3 to your computer and use it in GitHub Desktop.
Ethereum Contract 0x233820087a752349ee20daab1c18e0b7c546d3f6 : Finney Donation Gamble - Solidity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Doku see https://drive.google.com/file/d/0Bzjj9RC5wV6KRndsd1FQOGFPb0E/view?usp=sharing | |
contract FinneyDonationGamble { | |
// Basics | |
address foundation = 0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae; | |
// History | |
uint256 Bets_total_number; // Number of bets | |
uint256 Bets_since_last_win; // Number of bets since last win | |
uint256 Sum_of_Payouts; // Sum pay out | |
uint256 Sum_of_Donations; // Sum donations | |
uint256 Last_Block_Number; // Last block | |
uint256 Last_Bet_Size; // Message value | |
address Last_Player; // Last player address | |
uint256 Last_Win_Size; // Last amount won | |
uint256 Last_Winner_Bet; // Last bet amount won | |
address Last_Winner; // Last Winner | |
uint256 Highest_Donation_Bet; // Highest donation bet | |
address Highest_Donator; // Donator address | |
uint256 Highest_Payout; // Highest payout | |
address Highest_Winner; // Winner address | |
// Under_the_Hood | |
uint256 UtH_res; // Reslut | |
uint256 UtH_a; // 'Random' value | |
uint256 UtH_m; // Modulus | |
function Basics() | |
constant returns ( | |
uint256 Next_Payout_, // Next payout | |
uint256 Next_Donation_, | |
address foundation_) | |
{ | |
Next_Payout_ = this.balance/10/1000000000000000; | |
Next_Donation_ = this.balance*9/200/1000000000000000; | |
foundation_ = foundation; | |
} | |
function History() | |
constant returns ( | |
uint256 Bets_total_number_, // Number of bets | |
uint256 Bets_since_last_win_, // Number of bets since last win | |
uint256 Sum_of_Payouts_, // Sum pay out | |
uint256 Sum_of_Donations_, // Sum donations | |
uint256 Last_Block_Number_, // Last block | |
uint256 Last_Bet_Size_, // Message value | |
address Last_Player_, // Last player address | |
uint256 Last_Win_Size_, // Last amount won | |
uint256 Last_Winner_Bet_, // Last bet amount won | |
address Last_Winner_, // Last Winner | |
uint256 Highest_Donation_Bet_, // Highest donation bet | |
address Highest_Donator_, // Donator address | |
uint256 Highest_Payout_, // Highest payout | |
address Highest_Winner_) // Winner address | |
{ | |
Bets_total_number_ = Bets_total_number; // Number of bets | |
Bets_since_last_win_ = Bets_since_last_win; // Number of bets since last win | |
Sum_of_Payouts_ = Sum_of_Payouts/1000000000000000; // Sum pay out | |
Sum_of_Donations_ = Sum_of_Donations/1000000000000000; // Sum donations | |
Last_Block_Number_ = Last_Block_Number; // Last block | |
Last_Bet_Size_ = Last_Bet_Size/1000000000000000; // Message value | |
Last_Player_ = Last_Player; // Last player address | |
Last_Win_Size_ = Last_Win_Size/1000000000000000; // Last amount won | |
Last_Winner_Bet_ = Last_Winner_Bet/1000000000000000; // Last bet amount won | |
Last_Winner_ = Last_Winner; // Last Winner | |
Highest_Donation_Bet_= Highest_Donation_Bet/1000000000000000; // Highest donation bet | |
Highest_Donator_ = Highest_Donator; // Donator address | |
Highest_Payout_ = Highest_Payout/1000000000000000; // Highest payout | |
Highest_Winner_ = Highest_Winner; // Winner address | |
} | |
function Under_the_Hood() | |
constant returns ( | |
uint256 UtH_res_, // Reslut | |
uint256 UtH_a_, // 'Random' value | |
uint256 UtH_m_) // Modulus | |
{ | |
UtH_res_ = UtH_res; // Reslut | |
UtH_a_ = UtH_a; // 'Random' value | |
UtH_m_ = UtH_m; // Modulus | |
} | |
function () { | |
if (msg.value > 1000000000000000-1) { | |
Bets_total_number += 1; | |
Bets_since_last_win += 1; | |
Last_Block_Number = block.number; // Store the block number Last_Block_Number | |
Last_Bet_Size = msg.value; // Store the message value Last_Bet_Size in ether | |
Last_Player = msg.sender; // Store the last player | |
if (msg.value > Highest_Donation_Bet){ // Highest donation bet in ether | |
Highest_Donation_Bet = msg.value; | |
Highest_Donator = msg.sender; | |
} | |
UtH_a = UtH_a % block.timestamp + uint256(block.blockhash(block.number - 1)); | |
UtH_a = UtH_a + block.timestamp * block.difficulty * block.number + 1; | |
UtH_a = UtH_a % 80100011001110010011000010110111001101011011110018; | |
UtH_m = 10 + 10*1000000000000000000/msg.value; | |
UtH_res = UtH_a % UtH_m; // !!!!!!!!!!! | |
if (UtH_res == 0) { // Win | |
Bets_since_last_win = 0; // Reset the number of bets without win | |
Last_Win_Size = this.balance/10; // Last amount won | |
Last_Winner_Bet = msg.value; // Last bet amount won | |
Last_Winner = msg.sender; // Last Winner | |
if (this.balance/10 > Highest_Payout){ // Highest Donation Bet | |
Highest_Payout = this.balance/10; | |
Highest_Winner = msg.sender; | |
} | |
Sum_of_Payouts += this.balance/10; | |
msg.sender.send(this.balance/10); | |
Sum_of_Donations += this.balance/20; | |
foundation.send(this.balance/20); | |
} | |
} | |
} | |
} | |
https://chriseth.github.io/browser-solidity/ | |
Solidity version: 0.2.0-67c855c5 | |
v0.2.0-2016-01-20-76c855c | |
Enable Optimization | |
https://gist.github.com/anonymous/f224722552fd575eaede | |
CONTRACT BYTE CODE | |
606060405260008054600160a060020a03191673de0b295669a9fd93d5f28d9ec85e40f4cb697bae1781556102b390819061003990396000f3606060405236156100355760e060020a60003504632004dff681146101bd57806384ebde5214610202578063c0aa18e714610210575b6102b166038d7ea4c67fff3411156101bb5760018054810181556002805490910190554360055534600681905560078054600160a060020a03191633179055600b549011156100955734600b55600c8054600160a060020a031916331790555b601080547436ce80b791850e292b0f092bb007da9065615204824360001981014042938490060144939093020291909101600101069081905534678ac7230489e8000004600a0160118190559006600f819055600014156101bb576000600255600a30600160a060020a03168031829004600855346009558154600160a060020a03191633178255600d54903191909104111561015057600a30600160a060020a03163104600d55600e8054600160a060020a031916331790555b60038054600a600160a060020a0330811680318390049093019093553392909216916000913104606082818181858883f15050600480546014600160a060020a033081168031839004909301909355845460405193169550903104915082818181858883f150505050505b565b60005466038d7ea4c68000600a600160a060020a033081168031929092048390049360c89231600902929092049290920491165b606092835260809190915260a05280f35b600f546010546011546101f1565b600154600254600354600454600554600654600754600854600954600a54600b54600c54600d54600e5460609d8e5260809c909c5266038d7ea4c680009a8b900460a052988a900460c05260e0979097529488900461010052600160a060020a0393841661012052918790046101405286900461016052811661018052908490046101a0529081166101c0908152929091046101e052919091166102005290f35b00 | |
JSON INTERFACE | |
[{"constant":true,"inputs":[],"name":"Basics","outputs":[{"name":"Next_Payout_","type":"uint256"},{"name":"Next_Donation_","type":"uint256"},{"name":"foundation_","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"Under_the_Hood","outputs":[{"name":"UtH_res_","type":"uint256"},{"name":"UtH_a_","type":"uint256"},{"name":"UtH_m_","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"History","outputs":[{"name":"Bets_total_number_","type":"uint256"},{"name":"Bets_since_last_win_","type":"uint256"},{"name":"Sum_of_Payouts_","type":"uint256"},{"name":"Sum_of_Donations_","type":"uint256"},{"name":"Last_Block_Number_","type":"uint256"},{"name":"Last_Bet_Size_","type":"uint256"},{"name":"Last_Player_","type":"address"},{"name":"Last_Win_Size_","type":"uint256"},{"name":"Last_Winner_Bet_","type":"uint256"},{"name":"Last_Winner_","type":"address"},{"name":"Highest_Donation_Bet_","type":"uint256"},{"name":"Highest_Donator_","type":"address"},{"name":"Highest_Payout_","type":"uint256"},{"name":"Highest_Winner_","type":"address"}],"type":"function"}] | |
// Donations going to | |
https://etherchain.org/account/0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae#txreceived | |
// On the testnet try 0xc0cd30de8fbe76ebe4e14bdb2667436e05f7cfc9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment