Smart Contract Details
Open on Dero ExplorerInternal ID:
10476
Hash / Transaction:
Block:
Timestamp:
2022-12-22 20:31:59 UTC (2.7 years ago)
Creator:
…qgv26xst
(1414481)
Raw Data:
[{"name":"SC_ACTION","datatype":"U","value":1},{"name":"SC_CODE","datatype":"S","value":"// Raffle\n\n Function Raffle() Uint64\n\t10 dim deposit_count,winner as Uint64\n\t20 LET deposit_count = LOAD(\"deposit_count\")+1\n\t25 IF DEROVALUE() == 0 THEN GOTO 110 \n\t30 STORE(\"depositor_address\" + (deposit_count-1), SIGNER())\n\t40 STORE(\"deposit_total\", LOAD(\"deposit_total\") + DEROVALUE() )\n\t50 STORE(\"deposit_count\",deposit_count)\n\t60 IF LOAD(\"raffleeveryXdeposit\") \u003e deposit_count THEN GOTO 110 \n\t70 LET winner = RANDOM() % deposit_count \n\t80 SEND_DERO_TO_ADDRESS(LOAD(\"depositor_address\" + winner) , LOAD(\"rafflegiveback\")*LOAD(\"deposit_total\")/10000)\n 90 STORE(\"deposit_count\", 0) \n\t100 STORE(\"deposit_total\", 0) \n\t110 RETURN 0\n\tEnd Function\n\n\tFunction Initialize() Uint64\n\t10 STORE(\"owner\", SIGNER()) \n\t20 STORE(\"raffleeveryXdeposit\", 3) \n\t30 STORE(\"rafflegiveback\", 9000)\n 40 STORE(\"note\", \"Welcome to the raffle\") \n\t50 STORE(\"deposit_count\", 0) \n\t60 STORE(\"deposit_total\", 0)\n\t70 RETURN 0 \n\tEnd Function \t\n\t\n\tFunction TuneRaffleParameters(input Uint64, raffleeveryXdeposit Uint64, rafflegiveback Uint64, note String) Uint64\n\t10 dim key,stored_owner as String\n\t20 dim value_uint64 as Uint64\n\t30 IF LOAD(\"owner\") == SIGNER() THEN GOTO 100\n\t40 RETURN 1\n\n\t100 STORE(\"raffleeveryXdeposit\", raffleeveryXdeposit) \n\t130 STORE(\"rafflegiveback\", rafflegiveback)\n 135 STORE(\"note\", note)\n\t140 RETURN 0\n\tEnd Function\n\t \n\tFunction TransferOwnership(newowner String) Uint64 \n\t10 IF LOAD(\"owner\") == SIGNER() THEN GOTO 30 \n\t20 RETURN 1\n\t30 STORE(\"tmpowner\",ADDRESS_RAW(newowner))\n\t40 RETURN 0\n\tEnd Function\n\t\n Function ClaimOwnership() Uint64 \n\t10 IF LOAD(\"tmpowner\") == SIGNER() THEN GOTO 30 \n\t20 RETURN 1\n\t30 STORE(\"owner\",SIGNER()) // ownership claim successful\n\t40 RETURN 0\n\tEnd Function\n\t\n Function Withdraw(amount Uint64) Uint64 \n\t10 IF LOAD(\"owner\") == SIGNER() THEN GOTO 30 \n\t20 RETURN 1\n\t30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)\n\t40 RETURN 0\n\tEnd Function\n\t\n Function UpdateCode( code String) Uint64 \n\t10 IF LOAD(\"owner\") == SIGNER() THEN GOTO 30 \n\t20 RETURN 1\n\t30 UPDATE_SC_CODE(code)\n\t40 RETURN 0\n\tEnd Function"}]
Code:
// Raffle
Function Raffle() Uint64
10 dim deposit_count,winner as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
25 IF DEROVALUE() == 0 THEN GOTO 110
30 STORE("depositor_address" + (deposit_count-1), SIGNER())
40 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE() )
50 STORE("deposit_count",deposit_count)
60 IF LOAD("raffleeveryXdeposit") > deposit_count THEN GOTO 110
70 LET winner = RANDOM() % deposit_count
80 SEND_DERO_TO_ADDRESS(LOAD("depositor_address" + winner) , LOAD("rafflegiveback")*LOAD("deposit_total")/10000)
90 STORE("deposit_count", 0)
100 STORE("deposit_total", 0)
110 RETURN 0
End Function
Function Initialize() Uint64
10 STORE("owner", SIGNER())
20 STORE("raffleeveryXdeposit", 3)
30 STORE("rafflegiveback", 9000)
40 STORE("note", "Welcome to the raffle")
50 STORE("deposit_count", 0)
60 STORE("deposit_total", 0)
70 RETURN 0
End Function
Function TuneRaffleParameters(input Uint64, raffleeveryXdeposit Uint64, rafflegiveback Uint64, note String) Uint64
10 dim key,stored_owner as String
20 dim value_uint64 as Uint64
30 IF LOAD("owner") == SIGNER() THEN GOTO 100
40 RETURN 1
100 STORE("raffleeveryXdeposit", raffleeveryXdeposit)
130 STORE("rafflegiveback", rafflegiveback)
135 STORE("note", note)
140 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 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 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