Registers
TVM registers hold special values, such as contract storage, list of output actions, or exception handler
Only c4 (new state) and c5 (final actions) represent durable effects of a successful on‑chain run. Everything else is transient.
c0 — return continuation
Type: Continuation
Initial value: Quit — extraordinary continuation which terminates TVM with exit code 0.
When RET is called or the current continuation remains no instructions (implicit ret), c0 is invoked. Call-like instructions use it to store the current continuation in order to return to it after executing the inner function.
c1 — alternative return continuation
Type: Continuation
Initial value: Quit — extraordinary continuation which terminates TVM with exit code 1. Both exit codes 0 and 1 are considered successful terminations of TVM.
Same as c0, but invoked only in special control flow instructions, such as RETALT, IFRETALT, and others.
c2 — exception handler
Type: Continuation
Initial value: ExcQuit — extraordinary continuation which terminates TVM with an exception. In this case, the exit code is an exception number.
Invoked implicitly on any exception that occurs during TVM execution. Can be invoked explicitly by THROW-like instructions. To set a custom exception handler, use TRY.
c3 — function selector
Type: Continuation
Initial value: Root cell of code currently executing in TVM.
Invoked by CALLDICT instruction with a function ID (integer) passed on the stack. The function selector should jump to a function with that ID.
Fift-ASM assembler constructs following function selector (Asm.fif:1624):
SETCP0
<{
// a dictionary which maps 19-bit function id (integer) => function code (slice)
}> DICTPUSHCONST
DICTIGETJMPZ // get a function with given id from dictionary and execute it
11 THROWARG // if no function found, throw with exit code 11 and function id as additional argumentc4 — persistent account storage
Type: Cell
Initial value: Root cell of account data.
This register helps to store some information between smart contract invocations. When the transaction succeeds, the final value of c4 is saved as new account data.
c5 — outbound actions accumulator
Type: Cell
Initial value: Empty cell.
List of actions to perform in the action phase after TVM execution: send a message, reserve funds, update code, and install libraries.
c5 has an OutList structure:
out_list_empty$_ = OutList 0;
out_list$_ {n:#} prev:^(OutList n) action:OutAction = OutList (n + 1);
action_send_msg#0ec3c86d mode:(## 8) out_msg:^(MessageRelaxed Any) = OutAction;
action_set_code#ad4de08e new_code:^Cell = OutAction;
action_reserve_currency#36e6b809 mode:(## 8) currency:CurrencyCollection = OutAction;
libref_hash$0 lib_hash:bits256 = LibRef;
libref_ref$1 library:^Cell = LibRef;
action_change_library#26fa1dd4 mode:(## 7) libref:LibRef = OutAction;The previous action is always the first reference of the next one. If action itself has a reference, it is stored as the second reference in the list. At the beginning of the list, an empty cell is stored as the first reference of the first action.
c7 — environment information and global variables
Type: Tuple
Initial value: Tuple[Tuple[0x076ef1ea, 0, 0, ...]].
The zero element of the c7 tuple is an environment information (which itself is also a tuple). The remaining 255 slots are used for global variables. [i] SETGLOB modifies c7, inserting an element with index i, [i] GETGLOB reads i-th element from c7.
Structure of environment information tuple
| # | Instruction | Field | Type | Description |
|---|---|---|---|---|
| 0 | - | 0x076ef1ea | integer | tag of the SmartContractInfo TL-B structure |
| 1 | - | actions count | integer | increments when new action is pushed to c5. |
| 2 | - | messages sent | integer | increments when new action_send_msg is pushed to c5 |
| 3 | NOW | unix time | integer | current time (timestamp of block collation) |
| 4 | BLOCKLT | current block LT (logical time) | integer | |
| 5 | LTIME | current transaction LT | integer | |
| 6 | RANDSEED | random seed | integer | sha256(block_rand_seed . account_address) |
| 7 | BALANCE | smart contract balance | tuple | tuple of integer (TON balance) and cell or null (extra currencies dictionary) |
| 8 | MYADDR | smart contract address | slice | |
| 9 | CONFIGROOT | global blockchain configuration | cell or null (dictionary) | |
| 10 | MYCODE | smart contract code | cell | |
| 11 | INCOMINGVALUE | value of incoming message | tuple | tuple of integer (TON value) and cell or null (extra currencies dictionary) |
| 12 | STORAGEFEES | fees collected during storage phase | integer | |
| 13 | PREVBLOCKSINFOTUPLE, PREVMCBLOCKS_100 | last 16 masterchain blocks, last keyblock, and last 16 masterchain blocks with seqno divisible by 100 | tuple | tuple has following |
| 14 | UNPACKEDCONFIGTUPLE | unpacked config values | tuple |
|
| 15 | DUEPAYMENT | current debt for storage fee in nanotons | integer | |
| 16 | GETPRECOMPILEDGAS | gas usage for the current contract if it is precompiled, null otherwise | integer or null | see ConfigParam 45 |
| 17 | INMSGPARAMS | inbound message parameters | tuple |
For external messages, tick-tock transactions and get methods: |
Last updated on