Skip to main content
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):
Fift
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 argument

c4 — 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:
TLB
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

#InstructionFieldTypeDescription
0-0x076ef1eaintegertag of SmartContractInfo TLB structure
1-actions countintegerincrements when new action is pushed to c5.
2-messages sentintegerincrements when new action_send_msg is pushed to c5
3NOWunix timeintegercurrent time (timestamp of block collation)
4BLOCKLTcurrent block LT (logical time)integer
5LTIMEcurrent transaction LTinteger
6RANDSEEDrandom seedintegersha256(block_rand_seed . account_address)
7BALANCEsmart contract balancetupletuple of integer (TON balance) and cell/null (extra currencies dictionary)
8MYADDRsmart contract addressslice
9CONFIGROOTglobal blockchain configurationcell/null (dictionary)
10MYCODEsmart contract codecell
11INCOMINGVALUEvalue of incoming messagetupletuple of integer (TON value) and cell/null (extra currencies dictionary)
12STORAGEFEESfees collected during storage phaseinteger
13PREVBLOCKSINFOTUPLE, PREVMCBLOCKS_100last 16 masterchain blocks, last keyblock, and last 16 masterchain blocks with seqno divisible by 100tupletuple has following PrevBlocksInfo structure:
[ wc:Integer shard:Integer seqno:Integer
root_hash:Integer file_hash:Integer ]
= BlockId;
 
[ last_mc_blocks:BlockId[]
prev_key_block:BlockId
last_mc_blocks_divisible_by_100:BlockId[] ]
= PrevBlocksInfo;
14UNPACKEDCONFIGTUPLEunpacked config valuestuple
  • 0: StoragePrices from ConfigParam 18. Not the whole dict, but only the one StoragePrices entry (one which corresponds to the current time)
  • 1: ConfigParam 19 (global id)
  • 2: ConfigParam 20 (mc gas prices)
  • 3: ConfigParam 21 (gas prices)
  • 4: ConfigParam 24 (mc fwd fees)
  • 5: ConfigParam 25 (fwd fees)
  • 6: ConfigParam 43 (size limits)
15DUEPAYMENTcurrent debt for storage fee (nanotons)integer
16GETPRECOMPILEDGASgas usage for the current contract if it is precompiled, null otherwiseinteger/nullsee ConfigParam 45
17INMSGPARAMSinbound message parameterstuple
  • 0: bounce (boolean)
  • 1: bounced (boolean)
  • 2: src_addr (slice)
  • 3: fwd_fee (int)
  • 4: created_lt (int)
  • 5: created_at (int)
  • 6: orig_value (int) - this is sometimes different from the value in INCOMINGVALUE and TVM stack because of storage fees
  • 8: value (int) - same as in INCOMINGVALUE and TVM stack
  • 9: value_extra (cell or null) - same as in INCOMINGVALUE
  • 10: state_init (cell or null)
For external messages, tick-tock transactions and get methods: bounce, bounced, fwd_fee, created_lt, created_at, orig_value, value are 0, value_extra is null.

For tick-tock transactions and get methods: src_addr is addr_none.