> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ton.org/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.ton.org/feedback

```json
{
  "path": "/tvm/registers",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# 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`](/tvm/instructions#db30-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`](/tvm/instructions#db31-retalt), [`IFRETALT`](/tvm/instructions#e308-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`](/tvm/instructions#f2c4_-throw)-like instructions. To set a custom exception handler, use [TRY](/tvm/instructions#f2ff-try).

## `c3` — function selector

**Type**: Continuation

**Initial value**: Root cell of code currently executing in TVM.

Invoked by [`CALLDICT`](/tvm/instructions#f0-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](https://github.com/ton-blockchain/ton/blob/4ebd7412c52248360464c2df5f434c8aaa3edfe1/crypto/fift/lib/Asm.fif#L1624)):

```fift Fift theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
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 title="TL-B" theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
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`](/tvm/instructions#f87_-setglob) modifies `c7`, inserting an element with index `i`, [`[i] GETGLOB`](/tvm/instructions#f85_-getglob) reads `i`-th element from `c7`.

### Structure of environment information tuple

<table>
  <thead>
    <tr class="text-left">
      <th>#</th>
      <th>Instruction</th>
      <th>Field</th>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>0</td>
      <td>-</td>
      <td>0x076ef1ea</td>
      <td>integer</td>
      <td>tag of the <code>SmartContractInfo</code> TL-B structure</td>
    </tr>

    <tr>
      <td>1</td>
      <td>-</td>
      <td>actions count</td>
      <td>integer</td>
      <td>increments when new action is pushed to `c5`.</td>
    </tr>

    <tr>
      <td>2</td>
      <td>-</td>
      <td>messages sent</td>
      <td>integer</td>
      <td>increments when new `action_send_msg` is pushed to `c5`</td>
    </tr>

    <tr>
      <td>3</td>
      <td>NOW</td>
      <td>unix time</td>
      <td>integer</td>
      <td>current time (timestamp of block collation)</td>
    </tr>

    <tr>
      <td>4</td>
      <td>BLOCKLT</td>
      <td>current block LT (logical time)</td>
      <td>integer</td>

      <td />
    </tr>

    <tr>
      <td>5</td>
      <td>LTIME</td>
      <td>current transaction LT</td>
      <td>integer</td>

      <td />
    </tr>

    <tr>
      <td>6</td>
      <td>RANDSEED</td>
      <td>random seed</td>
      <td>integer</td>
      <td>`sha256(block_rand_seed . account_address)`</td>
    </tr>

    <tr>
      <td>7</td>
      <td>BALANCE</td>
      <td>smart contract balance</td>
      <td>tuple</td>
      <td>tuple of integer (TON balance) and cell or `null` (extra currencies dictionary)</td>
    </tr>

    <tr>
      <td>8</td>
      <td>MYADDR</td>
      <td>smart contract address</td>
      <td>slice</td>

      <td />
    </tr>

    <tr>
      <td>9</td>
      <td>CONFIGROOT</td>
      <td>global blockchain configuration</td>
      <td>cell or `null` (dictionary)</td>

      <td />
    </tr>

    <tr>
      <td>10</td>
      <td>MYCODE</td>
      <td>smart contract code</td>
      <td>cell</td>

      <td />
    </tr>

    <tr>
      <td>11</td>
      <td>INCOMINGVALUE</td>
      <td>value of incoming message</td>
      <td>tuple</td>
      <td>tuple of integer (TON value) and cell or `null` (extra currencies dictionary)</td>
    </tr>

    <tr>
      <td>12</td>
      <td>STORAGEFEES</td>
      <td>fees collected during storage phase</td>
      <td>integer</td>

      <td />
    </tr>

    <tr>
      <td>13</td>
      <td>PREVBLOCKSINFOTUPLE, PREVMCBLOCKS\_100</td>
      <td>last 16 masterchain blocks, last keyblock, and last 16 masterchain blocks with seqno divisible by 100</td>
      <td>tuple</td>

      <td>
        tuple has following `PrevBlocksInfo` structure:

        ```tlb theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
        [ 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;
        ```
      </td>
    </tr>

    <tr>
      <td>14</td>
      <td>UNPACKEDCONFIGTUPLE</td>
      <td>unpacked config values</td>
      <td>tuple</td>

      <td>
        * 0: `StoragePrices` from the `ConfigParam 18` — not the whole dictionary, but only the one `StoragePrices` entry which corresponds to the current time
        * 1: `ConfigParam 19`, global ID
        * 2: `ConfigParam 20`, masterchain gas prices
        * 3: `ConfigParam 21`, non-masterchain gas prices
        * 4: `ConfigParam 24`, masterchain forward fees
        * 5: `ConfigParam 25`, non-masterchain forward fees
        * 6: `ConfigParam 43`, size limits
      </td>
    </tr>

    <tr>
      <td>15</td>
      <td>DUEPAYMENT</td>
      <td>current debt for storage fee in nanotons</td>
      <td>integer</td>

      <td />
    </tr>

    <tr>
      <td>16</td>
      <td>GETPRECOMPILEDGAS</td>
      <td>gas usage for the current contract if it is precompiled, <code>null</code> otherwise</td>
      <td>integer or `null`</td>
      <td>see `ConfigParam 45`</td>
    </tr>

    <tr>
      <td>17</td>
      <td>INMSGPARAMS</td>
      <td>inbound message parameters</td>
      <td>tuple</td>

      <td>
        * 0: `bounce: boolean` — can bounce
        * 1: `bounced: boolean` — did bounce
        * 2: `src_addr: slice` — sender
        * 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
        * 7: `value: int` — same as in `INCOMINGVALUE` and on the initial TVM stack
        * 8: `value_extra: cell or null` — same as in `INCOMINGVALUE`
        * 9: `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.<br /><br /> For tick-tock transactions and get methods, `src_addr` is `addr_none`.
      </td>
    </tr>
  </tbody>
</table>
