SC CODE: // Data Store
Function DataStore(a String, x String) Uint64
10 dim deposit_count as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
30 IF DEROVALUE() == 0 THEN GOTO 130
40 STORE("depositor_address" + (deposit_count-1), SIGNER())
50 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE() )
60 STORE("deposit_count",deposit_count)
70 STORE("alias" + (deposit_count-1), a)
80 STORE("x" + (deposit_count-1), x)
90 IF deposit_count < LOAD("max_deposit") THEN GOTO 130
100 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
110 STORE("deposit_count", 0)
120 STORE("deposit_total", 0)
130 RETURN 0
End Function
Function ViewAddress(value Uint64)
10 IF SIGNER() == LOAD("owner") THEN GOTO 30
20 RETURN 0
30 RETURN LOAD("depositor_address" + value)
End Function
Function ViewAlias(value Uint64)
10 IF SIGNER() == address_raw("dero1qyd2vnxncqch4jknxzmfkf4jrvck9vakklx0xcufv9apptqx8qlu6qgv26xst") THEN GOTO 30
20 RETURN 0
30 RETURN LOAD("alias" + value)
End Function
Function ViewX(value Uint64)
10 RETURN LOAD("x" + value)
End Function
Function InitializePrivate() Uint64
10 IF SIGNER() == address_raw("dero1qyd2vnxncqch4jknxzmfkf4jrvck9vakklx0xcufv9apptqx8qlu6qgv26xst") THEN GOTO 30
20 RETURN 0
30 version("1.1.0")
40 STORE("owner", SIGNER())
50 STORE("deposit_count", 0)
60 STORE("deposit_total", 0)
70 STORE("max_deposit", 4)
80 STORE("readme", "Contract")
90 STORE("alias", "Init alias")
100 STORE("x", "Init x")
110 RETURN 0
End Function
Function TuneParameters(count Uint64, note String, a String, x String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("max_deposit", count)
40 STORE("readme", note)
50 STORE("alias", a)
60 STORE("x", x)
70 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
// Transfer
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:'// Data Store
Function DataStore(a String, x String) Uint64
10 dim deposit_count as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
30 IF DEROVALUE() == 0 THEN GOTO 130
40 STORE("depositor_address" + (deposit_count-1), SIGNER())
50 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE() )
60 STORE("deposit_count",deposit_count)
70 STORE("alias" + (deposit_count-1), a)
80 STORE("x" + (deposit_count-1), x)
90 IF deposit_count < LOAD("max_deposit") THEN GOTO 130
100 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
110 STORE("deposit_count", 0)
120 STORE("deposit_total", 0)
130 RETURN 0
End Function
Function ViewAddress(value Uint64)
10 IF SIGNER() == LOAD("owner") THEN GOTO 30
20 RETURN 0
30 RETURN LOAD("depositor_address" + value)
End Function
Function ViewAlias(value Uint64)
10 IF SIGNER() == address_raw("dero1qyd2vnxncqch4jknxzmfkf4jrvck9vakklx0xcufv9apptqx8qlu6qgv26xst") THEN GOTO 30
20 RETURN 0
30 RETURN LOAD("alias" + value)
End Function
Function ViewX(value Uint64)
10 RETURN LOAD("x" + value)
End Function
Function InitializePrivate() Uint64
10 IF SIGNER() == address_raw("dero1qyd2vnxncqch4jknxzmfkf4jrvck9vakklx0xcufv9apptqx8qlu6qgv26xst") THEN GOTO 30
20 RETURN 0
30 version("1.1.0")
40 STORE("owner", SIGNER())
50 STORE("deposit_count", 0)
60 STORE("deposit_total", 0)
70 STORE("max_deposit", 4)
80 STORE("readme", "Contract")
90 STORE("alias", "Init alias")
100 STORE("x", "Init x")
110 RETURN 0
End Function
Function TuneParameters(count Uint64, note String, a String, x String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("max_deposit", count)
40 STORE("readme", note)
50 STORE("alias", a)
60 STORE("x", x)
70 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
// Transfer
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'] |