Smart Contract Details
Open on Dero ExplorerInternal ID:
5910
Hash / Transaction:
Block:
Timestamp:
2022-11-23 19:27:41 UTC (2.8 years ago)
Creator:
…qgv26xst
(1414481)
Raw Data:
[{"name":"SC_ACTION","datatype":"U","value":1},{"name":"SC_CODE","datatype":"S","value":"// Issue tokens after depositing DERO (Convert DERO to TOKENX)\nFunction IssueTOKENX() Uint64\n 10 SEND_ASSET_TO_ADDRESS(SIGNER(),DEROVALUE(),SCID()) // Increment balance of user, without knowing original balance, this is done homomorphically\n 20 RETURN 0\n End Function\n\n // Convert TOKENX to DERO after depositing TOKENX. Smart Contract can give DERO, Only if DERO balance exists.\n Function ConvertTOKENX() Uint64\n 10 SEND_DERO_TO_ADDRESS(SIGNER(),ASSETVALUE(SCID())) // Increment balance of user, without knowing original balance, this is done using Homomorphic Encryption.\n 20 RETURN 0\n End Function\n\n// This function is used to initialize parameters during install time\n// InitializePrivate initializes a private SC\nFunction InitializePrivate() Uint64\n 10 STORE(\"owner\", SIGNER()) // Store in DB [\"owner\"] = address\n 20 STORE(\"number\",5)\n 30 STORE(\"text\",\"hello world dero\")\n 40 SEND_ASSET_TO_ADDRESS(SIGNER(), 40000000, SCID()) // Gives initial encrypted balance of 1600000.\n 50 RETURN 0\n End Function\n\n// Change number and text\nFunction ChangeNumberAndText(new_number Uint64, new_text String)\n 10 STORE(\"number\",new_number)\n 20 STORE(\"text\",new_text)\n 30 RETURN 0\n END FUNCTION\n \n// This function is used to change owner\n// owner is an string form of address\nFunction TransferOwnership(newowner String) Uint64\n 10 IF LOAD(\"owner\") == SIGNER() THEN GOTO 30\n 20 RETURN 1\n 30 STORE(\"tmpowner\",ADDRESS_RAW(newowner))\n 40 RETURN 0\n End Function\n\n// Until the new owner claims ownership, existing owner remains owner\nFunction ClaimOwnership() Uint64\n 10 IF LOAD(\"tmpowner\") == SIGNER() THEN GOTO 30\n 20 RETURN 1\n 30 STORE(\"owner\",SIGNER()) // ownership claim successful\n 40 RETURN 0\n End Function\n\n// if signer is owner, withdraw any requested funds\n// if everthing is okay, they will be showing in signers wallet\nFunction Withdraw(amount Uint64) Uint64\n 10 IF LOAD(\"owner\") == SIGNER() THEN GOTO 30\n 20 RETURN 1\n 30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)\n 40 RETURN 0\n End Function\n\n// if signer is owner, provide him rights to update code anytime\n// make sure update is always available to SC\nFunction UpdateCode(code String) Uint64\n 10 IF LOAD(\"owner\") == SIGNER() THEN GOTO 30\n 20 RETURN 1\n 30 UPDATE_SC_CODE(code)\n 40 RETURN 0\n End Function"}]
Code:
// Issue tokens after depositing DERO (Convert DERO to TOKENX)
Function IssueTOKENX() Uint64
10 SEND_ASSET_TO_ADDRESS(SIGNER(),DEROVALUE(),SCID()) // Increment balance of user, without knowing original balance, this is done homomorphically
20 RETURN 0
End Function
// Convert TOKENX to DERO after depositing TOKENX. Smart Contract can give DERO, Only if DERO balance exists.
Function ConvertTOKENX() Uint64
10 SEND_DERO_TO_ADDRESS(SIGNER(),ASSETVALUE(SCID())) // Increment balance of user, without knowing original balance, this is done using Homomorphic Encryption.
20 RETURN 0
End Function
// This function is used to initialize parameters during install time
// InitializePrivate initializes a private SC
Function InitializePrivate() Uint64
10 STORE("owner", SIGNER()) // Store in DB ["owner"] = address
20 STORE("number",5)
30 STORE("text","hello world dero")
40 SEND_ASSET_TO_ADDRESS(SIGNER(), 40000000, SCID()) // Gives initial encrypted balance of 1600000.
50 RETURN 0
End Function
// Change number and text
Function ChangeNumberAndText(new_number Uint64, new_text String)
10 STORE("number",new_number)
20 STORE("text",new_text)
30 RETURN 0
END FUNCTION
// This function is used to change owner
// owner is an string form of address
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
// Until the new owner claims ownership, existing owner remains owner
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
// if signer is owner, withdraw any requested funds
// if everthing is okay, they will be showing in signers wallet
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
// if signer is owner, provide him rights to update code anytime
// make sure update is always available to SC
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