SC CODE: // Smart Raffle
Function SmartRaffle(a String, x String, y String) Uint64
10 dim deposit_count,win,min_play,active,max_deposit as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
30 LET min_play = LOAD("min_play")
40 LET active = LOAD("active")
50 LET max_deposit = LOAD("max_deposit")
60 IF active == 0 THEN GOTO 220
70 IF DEROVALUE() < min_play THEN GOTO 220
80 STORE("depositor_address" + (deposit_count-1), SIGNER())
90 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE())
100 STORE("deposit_count",deposit_count)
110 STORE("a" + (deposit_count-1), a)
120 STORE("x" + (deposit_count-1), x)
130 STORE("y" + (deposit_count-1), y)
140 IF deposit_count < max_deposit THEN GOTO 220
150 LET win = RANDOM() % deposit_count
160 STORE("winner",LOAD("a" + win))
170 STORE("winnum", win)
180 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
190 STORE("deposit_count", 0)
200 STORE("deposit_total", 0)
210 STORE("active", 0)
220 RETURN 0
End Function
Function InitializePrivate() Uint64
10 STORE("owner", SIGNER())
20 STORE("version","1.1.8")
30 STORE("deposit_count", 0)
40 STORE("deposit_total", 0)
50 STORE("max_deposit", 3)
60 STORE("min_play", 100)
70 STORE("readme", "Readme")
80 STORE("winner", "NA")
90 STORE("winnum", 1000000)
100 STORE("active", 0)
110 RETURN 0
End Function
Function ForceDraw() Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 dim deposit_count,win as Uint64
40 LET deposit_count = LOAD("deposit_count")
50 LET win = RANDOM() % deposit_count
60 STORE("winner",LOAD("a" + win))
70 STORE("winnum", win)
80 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
90 STORE("deposit_count", 0)
100 STORE("deposit_total", 0)
110 STORE("active", 0)
120 RETURN 0
End Function
Function ClearWinner() Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("winner", "")
40 STORE("winnum", 1000000)
50 RETURN 0
End Function
Function ClearEntry(i Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("a" + i, "")
40 STORE("x" + i, "")
50 STORE("y" + i, "")
60 RETURN 0
End Function
Function TuneParameters(note String, x Uint64, y Uint64, z Uint64, d Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("readme", note)
40 STORE("max_deposit", x)
50 STORE("min_play", y)
60 STORE("active", z)
70 STORE("deposit_total", d)
80 RETURN 0
End Function
Function Withdraw(amount Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)
40 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner",ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 IF LOAD("tmpowner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("owner",SIGNER()) // ownership claim successful
40 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 RETURN 0
End Function |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// Smart Raffle
Function SmartRaffle(a String, x String, y String) Uint64
10 dim deposit_count,win,min_play,active,max_deposit as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
30 LET min_play = LOAD("min_play")
40 LET active = LOAD("active")
50 LET max_deposit = LOAD("max_deposit")
60 IF active == 0 THEN GOTO 220
70 IF DEROVALUE() < min_play THEN GOTO 220
80 STORE("depositor_address" + (deposit_count-1), SIGNER())
90 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE())
100 STORE("deposit_count",deposit_count)
110 STORE("a" + (deposit_count-1), a)
120 STORE("x" + (deposit_count-1), x)
130 STORE("y" + (deposit_count-1), y)
140 IF deposit_count < max_deposit THEN GOTO 220
150 LET win = RANDOM() % deposit_count
160 STORE("winner",LOAD("a" + win))
170 STORE("winnum", win)
180 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
190 STORE("deposit_count", 0)
200 STORE("deposit_total", 0)
210 STORE("active", 0)
220 RETURN 0
End Function
Function InitializePrivate() Uint64
10 STORE("owner", SIGNER())
20 STORE("version","1.1.8")
30 STORE("deposit_count", 0)
40 STORE("deposit_total", 0)
50 STORE("max_deposit", 3)
60 STORE("min_play", 100)
70 STORE("readme", "Readme")
80 STORE("winner", "NA")
90 STORE("winnum", 1000000)
100 STORE("active", 0)
110 RETURN 0
End Function
Function ForceDraw() Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 dim deposit_count,win as Uint64
40 LET deposit_count = LOAD("deposit_count")
50 LET win = RANDOM() % deposit_count
60 STORE("winner",LOAD("a" + win))
70 STORE("winnum", win)
80 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
90 STORE("deposit_count", 0)
100 STORE("deposit_total", 0)
110 STORE("active", 0)
120 RETURN 0
End Function
Function ClearWinner() Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("winner", "")
40 STORE("winnum", 1000000)
50 RETURN 0
End Function
Function ClearEntry(i Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("a" + i, "")
40 STORE("x" + i, "")
50 STORE("y" + i, "")
60 RETURN 0
End Function
Function TuneParameters(note String, x Uint64, y Uint64, z Uint64, d Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("readme", note)
40 STORE("max_deposit", x)
50 STORE("min_play", y)
60 STORE("active", z)
70 STORE("deposit_total", d)
80 RETURN 0
End Function
Function Withdraw(amount Uint64) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)
40 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner",ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 IF LOAD("tmpowner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("owner",SIGNER()) // ownership claim successful
40 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 RETURN 0
End Function'] |