SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// Smart Raffle
Function InitializePrivate() Uint64
10 STORE("owner", SIGNER())
20 STORE("version","1.1.5")
30 STORE("deposit_count", 0)
40 STORE("deposit_total", 0)
50 STORE("max_deposit", 2)
60 STORE("min_play", 0.001)
70 STORE("readme", "")
80 STORE("winner", "")
90 STORE("winnum", "")
100 STORE("active", 0)
110 RETURN 0
End Function
Function SmartRaffle(a String, x String, y String, z String) Uint64
10 dim deposit_count,win as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
30 IF LOAD("active") == 0 THEN GOTO 200
40 IF DEROVALUE() < LOAD("min_play") THEN GOTO 200
50 STORE("depositor_address" + (deposit_count-1), SIGNER())
60 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE() )
70 STORE("deposit_count",deposit_count)
80 STORE("a" + (deposit_count-1), a)
90 STORE("x" + (deposit_count-1), x)
100 STORE("y" + (deposit_count-1), y)
110 STORE("z" + (deposit_count-1), z)
120 IF deposit_count < LOAD("max_deposit") THEN GOTO 200
130 LET win = RANDOM() % deposit_count
140 STORE("winner",LOAD("a" + win))
150 STORE("winnum", win)
160 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
170 STORE("deposit_count", 0)
180 STORE("deposit_total", 0)
190 STORE("active", 0)
200 RETURN 0
End Function
'] |