Skip to content

Instantly share code, notes, and snippets.

@larskluge
Created May 8, 2014 06:23
Show Gist options
  • Save larskluge/a3e6c8d225fd8e50709e to your computer and use it in GitHub Desktop.
Save larskluge/a3e6c8d225fd8e50709e to your computer and use it in GitHub Desktop.
Spinjar as Ethereum Contract
{
; Initialization
[[0x0]] (caller) ; Admin!
[[0x1]] 0x100 ; How often should the draw happen?
[0x0] "Spinjar" ; Name of our contract
(call 0x929b11b8eeea00966e873a241d4b67f7540d1f38 0 0 0 7 0 0) ; Register with name registration
}
{
(when (= (caller) @@0x0)
{
[0x0] (calldataload 0)
(when (= @0x0 "kill") ; If the admin calls it with data kill deregister + suicide
{
(call 0x929b11b8eeea00966e873a241d4b67f7540d1f38 0 0 0 0 0 0)
(suicide)
}
)
}
)
[0x0] (DIV(MUL (callvalue) 7) 10) ; 70% of donation for project forward
[0x80](calldataload 0) ; Address of recipient
(call @0x80 @0x0 0 0 0 0 0)
[0x20] (prevhash)
[0x40] (timestamp)
[0x60] (SHA3 0x20 0x40)
(when (= (MOD @0x60 @@0x1) 0) ; Random chance on every ticket purchase for a draw to occur
{
[0xA0] (MUL 100 (callvalue))
[0xC0] (DIV (MUL (balance) 8) 10) ; Max jackpot amount
(if (> @0xA0 @0xC0) ; compare 100*sent amount to 80% of balance
{
(call (caller) @0xC0 0 0 0 0 0) ; Full payout will be too much, send max
}
{
(call (caller) @0xA0 0 0 0 0 0) ; Full payout is less then max, send full
}
)
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment