SC CODE: // SendBack
Function InitializePrivate() Uint64
10 IF SIGNER() == address_raw("dero1qyd2vnxncqch4jknxzmfkf4jrvck9vakklx0xcufv9apptqx8qlu6qgv26xst") THEN GOTO 30
20 RETURN 0
30 version("1.2.3")
40 STORE("owner", SIGNER())
50 STORE("returneveryXdeposit", 2)
60 STORE("readme", "Welcome to Dreturn. Return to signer after X number of deposits.")
70 STORE("deposit_count", 0)
80 STORE("deposit_total", 0)
90 RETURN 0
End Function
Function DeroReturn() Uint64
10 dim deposit_count as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
30 IF DEROVALUE() == 0 THEN GOTO 100
40 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE() )
50 STORE("deposit_count", deposit_count)
60 IF LOAD("returneveryXdeposit") > deposit_count THEN GOTO 100
70 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
80 STORE("deposit_count", 0)
90 STORE("deposit_total", 0)
100 RETURN 0
End Function
Function TuneParameters(returneveryXdeposit Uint64, note String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("returneveryXdeposit", returneveryXdeposit)
40 STORE("readme", note)
50 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 |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// SendBack
Function InitializePrivate() Uint64
10 IF SIGNER() == address_raw("dero1qyd2vnxncqch4jknxzmfkf4jrvck9vakklx0xcufv9apptqx8qlu6qgv26xst") THEN GOTO 30
20 RETURN 0
30 version("1.2.3")
40 STORE("owner", SIGNER())
50 STORE("returneveryXdeposit", 2)
60 STORE("readme", "Welcome to Dreturn. Return to signer after X number of deposits.")
70 STORE("deposit_count", 0)
80 STORE("deposit_total", 0)
90 RETURN 0
End Function
Function DeroReturn() Uint64
10 dim deposit_count as Uint64
20 LET deposit_count = LOAD("deposit_count")+1
30 IF DEROVALUE() == 0 THEN GOTO 100
40 STORE("deposit_total", LOAD("deposit_total") + DEROVALUE() )
50 STORE("deposit_count", deposit_count)
60 IF LOAD("returneveryXdeposit") > deposit_count THEN GOTO 100
70 SEND_DERO_TO_ADDRESS(LOAD("owner"),LOAD("deposit_total"))
80 STORE("deposit_count", 0)
90 STORE("deposit_total", 0)
100 RETURN 0
End Function
Function TuneParameters(returneveryXdeposit Uint64, note String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("returneveryXdeposit", returneveryXdeposit)
40 STORE("readme", note)
50 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'] |