derohe-miniblock-mod/guide/support_functions.md

75 lines
2.6 KiB
Markdown
Raw Normal View History

2021-02-28 16:01:03 +00:00
**Support Functions are inbuilt functions which provide some functionality or expose internals for speed and technical reasons.**
2021-02-22 17:48:14 +00:00
LOAD(variable)
==============
LOAD loads a variable which was previously stored in the blockchain using STORE function. Return type will be Uint64/String depending on what is stored.
2021-02-28 16:01:03 +00:00
It will panic if the value does NOT exists.
2021-02-22 17:48:14 +00:00
Uint64 EXISTS(variable)
=======================
2021-02-28 16:01:03 +00:00
EXISTS return 1 if the variable is store in DB and 0 otherwise.
2021-02-22 17:48:14 +00:00
STORE(key variable, value variable)
===================================
STORE stores key and value in the DB. All storage state of the SC is accessible only from the SC which created it.
2021-02-28 16:01:03 +00:00
Uint64 RANDOM() or Uint64 RANDOM(limit Uint64)
==============================================
2021-02-22 17:48:14 +00:00
RANDOM returns a random using a PRNG seeded on BLID,SCID,TXID. First form gives a uint64, second form returns
2021-02-28 16:01:03 +00:00
random number in the range 0 - (limit), 0 is inclusive, limit is exclusive.
2021-02-22 17:48:14 +00:00
String SCID()
==============
2021-02-28 16:01:03 +00:00
Returns SMART CONTRACT ID which is currently running.
2021-02-22 17:48:14 +00:00
String BLID()
==============
2021-02-28 16:01:03 +00:00
Returns current BLOCK ID which contains current execution-in-progress TXID.
2021-02-22 17:48:14 +00:00
String TXID()
=============
Returns current TXID which is execution-in-progress.
Uint64 BLOCK_HEIGHT()
=====================
2021-02-28 16:01:03 +00:00
Returns current chain height of BLID().
2021-02-22 17:48:14 +00:00
Uint64 BLOCK_TOPOHEIGHT()
===========================
2021-02-28 16:01:03 +00:00
Returns current topoheight of BLID().
2021-02-22 17:48:14 +00:00
String SIGNER()
=================
2021-02-28 16:01:03 +00:00
Returns address of who signed/sent this transaction. SIGNER() returns the raw address.
2021-02-22 17:48:14 +00:00
Uint64 IS_ADDRESS_VALID(p String)
=================================
2021-02-28 16:01:03 +00:00
Returns 1 if address is valid, 0 otherwise.
2021-02-22 17:48:14 +00:00
String ADDRESS_RAW(p String)
============================
2021-02-28 16:01:03 +00:00
Returns address in RAW form as 33 byte keys, stripping away textual/presentation form. Addresses should always be compared in RAW form.
2021-02-22 17:48:14 +00:00
SEND_DERO_TO_ADDRESS(a String, amount Uint64)
==============================================
2021-02-28 16:01:03 +00:00
Sends amount DERO from SC DERO balance to a address which should be raw form. address must in string form DERO/DETO form.
2021-02-22 17:48:14 +00:00
If the SC does not have enough balance, it will panic
ADD_VALUE(a String, amount Uint64)
====================================
Send specific number of token to specific account.
If account is bring touched for the first time, it is done simply.
2021-02-28 16:01:03 +00:00
If account is already initialized ( it already has some balance, but SC does not know how much). So, it gives additional balance homomorphically.
2021-02-22 17:48:14 +00:00
2021-02-28 16:01:03 +00:00
DEROVALUE()
============
DEROVALUE() gives DERO transacted/deposited in current transaction.
2021-02-22 17:48:14 +00:00
2021-02-28 16:01:03 +00:00
TOKENVALUE()
============
TOKENVALUE() gives particular token transacted/deposited in currrent transaction.