derohe-miniblock-mod/guide/support_functions.md
2021-02-28 16:01:03 +00:00

75 lines
2.6 KiB
Markdown

**Support Functions are inbuilt functions which provide some functionality or expose internals for speed and technical reasons.**
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.
It will panic if the value does NOT exists.
Uint64 EXISTS(variable)
=======================
EXISTS return 1 if the variable is store in DB and 0 otherwise.
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.
Uint64 RANDOM() or Uint64 RANDOM(limit Uint64)
==============================================
RANDOM returns a random using a PRNG seeded on BLID,SCID,TXID. First form gives a uint64, second form returns
random number in the range 0 - (limit), 0 is inclusive, limit is exclusive.
String SCID()
==============
Returns SMART CONTRACT ID which is currently running.
String BLID()
==============
Returns current BLOCK ID which contains current execution-in-progress TXID.
String TXID()
=============
Returns current TXID which is execution-in-progress.
Uint64 BLOCK_HEIGHT()
=====================
Returns current chain height of BLID().
Uint64 BLOCK_TOPOHEIGHT()
===========================
Returns current topoheight of BLID().
String SIGNER()
=================
Returns address of who signed/sent this transaction. SIGNER() returns the raw address.
Uint64 IS_ADDRESS_VALID(p String)
=================================
Returns 1 if address is valid, 0 otherwise.
String ADDRESS_RAW(p String)
============================
Returns address in RAW form as 33 byte keys, stripping away textual/presentation form. Addresses should always be compared in RAW form.
SEND_DERO_TO_ADDRESS(a String, amount Uint64)
==============================================
Sends amount DERO from SC DERO balance to a address which should be raw form. address must in string form DERO/DETO form.
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.
If account is already initialized ( it already has some balance, but SC does not know how much). So, it gives additional balance homomorphically.
DEROVALUE()
============
DEROVALUE() gives DERO transacted/deposited in current transaction.
TOKENVALUE()
============
TOKENVALUE() gives particular token transacted/deposited in currrent transaction.