---
title: Exit codes
description: "An exit code is a 32-bit signed integer, which indicates whether the compute or action phase of the transaction was successful, and if not — holds the code of the exception that occurred."
---

import { Badge } from '@astrojs/starlight/components';

Each transaction on TON Blockchain consists of [multiple phases](https://docs.ton.org/learn/tvm-instructions/tvm-overview#transactions-and-phases). An _exit code_ is a $32$-bit signed integer that indicates whether the [compute](#compute) or [action](#action) phase of the transaction was successful, and if not — holds the code of the exception that occurred. Each exit code represents its own exception or resulting state of the transaction.

Exit codes $0$ and $1$ indicate normal (successful) execution of the [compute phase](#compute). Exit (or [result](#action)) code $0$ indicates normal (successful) execution of the [action phase](#action). Any other exit code indicates that a certain exception has occurred and that the transaction was not successful in one way or another, i.e. the transaction was reverted or the inbound message has bounced back.

TON Blockchain reserves exit code values from $0$ to $127$, while Tact utilizes exit codes from $128$ to $255$. Note that exit codes used by Tact indicate contract errors, which can occur when using Tact-generated code, and are therefore thrown in the transaction's [compute phase](#compute) and not during compilation.

The range from $256$ to $65535$ is free for developer-defined exit codes.

:::note

  While an exit (or [result](#action)) code is a $32$-bit signed integer on TON Blockchain, an attempt to [throw](/ref/core-debug) an exit code outside the bounds of a $16$-bit unsigned integer ($0 - 65535$) will cause an error with [exit code 5](#5). This is done intentionally to prevent some exit codes from being produced artificially, such as [exit code -14](#-14).

:::

## Table of exit codes {#table}

The following table lists exit codes with their origin (where they can occur) and a short description for each. The table does not list the exit code of the [`require()`](/ref/core-debug#require), as it generates it depending on the concrete `error` message [String][p]. To see such exit codes, refer to the [Exit codes section of the compilation report](/book/compile#exit-codes).

Exit code     | Origin                              | Brief description
:------------ | :---------------------------------- | :----------------
[$0$](#0)     | [Compute][c] and [action][a] phases | Standard successful execution exit code.
[$1$](#1)     | [Compute phase][c]                  | Alternative successful execution exit code. Reserved, but does not occur.
[$2$](#2)     | [Compute phase][c]                  | Stack underflow.
[$3$](#3)     | [Compute phase][c]                  | Stack overflow.
[$4$](#4)     | [Compute phase][c]                  | Integer overflow.
[$5$](#5)     | [Compute phase][c]                  | Range check error — an integer is out of its expected range.
[$6$](#6)     | [Compute phase][c]                  | Invalid [TVM][tvm] opcode.
[$7$](#7)     | [Compute phase][c]                  | Type check error.
[$8$](#8)     | [Compute phase][c]                  | Cell overflow.
[$9$](#9)     | [Compute phase][c]                  | Cell underflow.
[$10$](#10)   | [Compute phase][c]                  | Dictionary error.
[$11$](#11)   | [Compute phase][c]                  | Described in [TVM][tvm] docs as "Unknown error, may be thrown by user programs."
[$12$](#12)   | [Compute phase][c]                  | Fatal error. Thrown by [TVM][tvm] in situations deemed impossible.
[$13$](#13)   | [Compute phase][c]                  | Out of gas error.
[$-14$](#-14) | [Compute phase][c]                  | Same as $13$. Negative, so that it [cannot be faked](#13).
[$14$](#14)   | [Compute phase][c]                  | VM virtualization error. Reserved, but never thrown.
[$32$](#32)   | [Action phase][a]                   | Action list is invalid.
[$33$](#33)   | [Action phase][a]                   | Action list is too long.
[$34$](#34)   | [Action phase][a]                   | Action is invalid or not supported.
[$35$](#35)   | [Action phase][a]                   | Invalid source address in outbound message.
[$36$](#36)   | [Action phase][a]                   | Invalid destination address in outbound message.
[$37$](#37)   | [Action phase][a]                   | Not enough Toncoin.
[$38$](#38)   | [Action phase][a]                   | Not enough extra currencies.
[$39$](#39)   | [Action phase][a]                   | Outbound message does not fit into a cell after rewriting.
[$40$](#40)   | [Action phase][a]                   | Cannot process a message — not enough funds, the message is too large, or its Merkle depth is too big.
[$41$](#41)   | [Action phase][a]                   | Library reference is null during library change action.
[$42$](#42)   | [Action phase][a]                   | Library change action error.
[$43$](#43)   | [Action phase][a]                   | Exceeded the maximum number of cells in the library or the maximum depth of the Merkle tree.
[$50$](#50)   | [Action phase][a]                   | Account state size exceeded limits.
[$128$](#128) | Tact compiler ([Compute phase][c])  | Null reference exception. Configurable since Tact 1.6.
[$129$](#129) | Tact compiler ([Compute phase][c])  | Invalid serialization prefix.
[$130$](#130) | Tact compiler ([Compute phase][c])  | Invalid incoming message — there is no receiver for the opcode of the received message.
[$131$](#131) | Tact compiler ([Compute phase][c])  | Constraints error. Reserved, but never thrown.
[$132$](#132) | Tact compiler ([Compute phase][c])  | Access denied — someone other than the owner sent a message to the contract.
[$133$](#133) | Tact compiler ([Compute phase][c])  | Contract stopped.
[$134$](#134) | Tact compiler ([Compute phase][c])  | Invalid argument.
[$135$](#135) | Tact compiler ([Compute phase][c])  | Code of a contract was not found.
[$136$](#136) | Tact compiler ([Compute phase][c])  | Invalid standard address.
~~[$137$](#137)~~ | ~~Tact compiler ([Compute phase][c])~~  | ~~Masterchain support is not enabled for this contract.~~ Removed since Tact 1.6.
[$138$](#138) | Tact compiler ([Compute phase][c])  | Not a basechain address. Available since Tact 1.6.3.

:::note

Often enough, you might encounter the exit code $65535$ (or `0xffff`), which usually means the same as the [exit code 130](#130) — the received opcode is unknown to the contract, as there were no receivers expecting it. When writing contracts, the exit code $65535$ is set by the developers and not by [TVM][tvm] or the Tact compiler.

:::

[c]: https://docs.ton.org/learn/tvm-instructions/tvm-overview#compute-phase
[a]: https://docs.ton.org/learn/tvm-instructions/tvm-overview#transactions-and-phases

## Exit codes in Blueprint projects {#blueprint}

In [Blueprint][bp] tests, exit codes from the [compute phase](#compute) are specified in the `exitCode` field of the object argument for the `toHaveTransaction(){:typescript}` method of the `expect(){:typescript}` matcher. The field for the [result](#action) codes (exit codes from the [action phase](#action)) in the same `toHaveTransaction(){:typescript}` method is called `actionResultCode`.

:::note

  Read more about expecting specific exit codes: [Transactions with intentional errors](/book/debug#tests-errors).

:::

Additionally, one can examine the result of [sending a message to a contract](/book/debug#tests-send) and discover the phases of each transaction and their values, including exit (or result) codes for the [compute phase](#compute) (or [action phase](#action)).

Note that to do so, you'll have to perform a couple of type checks first:

```typescript
it('tests something, you name it', async () => {
  // Send a specific message to our contract and store the results
  const res = await your_contract_name.send(…);

  // Now, we have access to an array of executed transactions,
  // with the second one (index 1) being the one we look for
  const tx = res.transactions[1]!;

  // To do something useful with it, let's ensure that its type is 'generic'
  // and that the compute phase in it wasn't skipped
  if (tx.description.type === "generic"
      && tx.description.computePhase.type === "vm") {
    // Finally, we're able to freely peek into the transaction for general details,
    // such as printing out the exit code of the compute phase if we so desire
    console.log(tx.description.computePhase.exitCode);
  }

  // ...
});
```

## Compute and action phases

### 0: Normal termination {#0}

This exit (or [result](#action)) code indicates the successful completion of the [compute phase](#compute) (or [action phase](#action)) of the transaction.

## Compute phase {#compute}

[TVM][tvm] initialization and all computations occur in the [compute phase][c].

If the compute phase fails (the resulting exit code is neither [$0$](#0) nor [$1$](#1)), the transaction skips the [action phase](#action) and proceeds to the bounce phase. In this phase, a bounce message is formed for transactions initiated by the inbound message.

### 1: Alternative termination {#1}

This is an alternative exit code for the successful execution of the [compute phase](#compute). It is reserved but never occurs.

### 2: Stack underflow {#2}

If an operation consumes more elements than exist on the stack, an error with exit code $2$ is thrown: `Stack underflow`.

```tact
asm fun drop() { DROP }

contract Loot {
    receive("I solemnly swear that I'm up to no good") {
        try {
            // Removes 100 elements from the stack, causing an underflow
            repeat (100) { drop() }
        } catch (exitCode) {
            // exitCode is 2
        }
    }
}
```

:::note[Useful links:]

  [TVM is a stack machine](https://docs.ton.org/learn/tvm-instructions/tvm-overview#tvm-is-a-stack-machine) in TON Docs.

:::

### 3: Stack overflow {#3}

If there are too many elements copied into a closure continuation, an error with exit code $3$ is thrown: `Stack overflow`. This occurs rarely unless you're deep in the [Fift and TVM assembly](https://docs.ton.org/develop/fift/fift-and-tvm-assembly) trenches:

```tact
// Remember kids, don't try to overflow the stack at home!
asm fun stackOverflow() {
    x{} SLICE        // s
    BLESS            // c
    0 SETNUMARGS     // c'
    2 PUSHINT        // c' 2
    SWAP             // 2 c'
    1 -1 SETCONTARGS // ← this blows up
}

contract ItsSoOver {
    receive("I solemnly swear that I'm up to no good") {
        try {
            stackOverflow();
        } catch (exitCode) {
            // exitCode is 3
        }
    }
}
```

:::note[Useful links:]

  [TVM is a stack machine](https://docs.ton.org/learn/tvm-instructions/tvm-overview#tvm-is-a-stack-machine) in TON Docs.

:::

### 4: Integer overflow {#4}

If the [value in a calculation](/book/integers#operations) goes beyond the range from $-2^{256}$ to $2^{256} - 1$ inclusive, or there's an attempt to [divide](/book/operators#binary-divide) or perform [modulo](/book/operators#binary-modulo) by zero, an error with exit code $4$ is thrown: `Integer overflow`.

```tact
let x = -pow(2, 255) - pow(2, 255); // -2^{256}

try {
    -x; // integer overflow by negation
        // since the max positive value is 2^{256} - 1
} catch (exitCode) {
    // exitCode is 4
}

try {
    x / 0; // division by zero!
} catch (exitCode) {
    // exitCode is 4
}

try {
    x * x * x; // integer overflow!
} catch (exitCode) {
    // exitCode is 4
}

// There can also be an integer overflow when performing:
// addition (+),
// subtraction (-),
// division (/) by a negative number or modulo (%) by zero
```

### 5: Integer out of expected range {#5}

A range check error occurs when [some integer](/book/integers#operations) is out of its expected range. Any attempt to store an unexpected amount of data or specify an out-of-bounds value throws an error with exit code $5$: `Integer out of expected range`.

Examples of specifying an out-of-bounds value:

```tact
try {
    // Repeat only operates on an inclusive range from 1 to 2^{31} - 1
    // Any valid integer value greater than that causes an error with exit code 5
    repeat (pow(2, 55)) {
        dump("smash. logs. I. must.");
    }
} catch (exitCode) {
    // exitCode is 5
}

try {
    // Builder.storeUint() function can only use up to 256 bits, thus 512 is too much:
    let s: Slice = beginCell().storeUint(-1, 512).asSlice();
} catch (exitCode) {
    // exitCode is 5
}
```

### 6: Invalid opcode {#6}

If you specify an instruction that is not defined in the current [TVM][tvm] version or attempt to set an unsupported [code page](https://docs.ton.org/v3/documentation/tvm/tvm-overview#tvm-state), an error with exit code $6$ is thrown: `Invalid opcode`.

```tact
// There's no such code page, and an attempt to set it fails
asm fun invalidOpcode() { 42 SETCP }

contract OpOp {
    receive("I solemnly swear that I'm up to no good") {
        try {
            invalidOpcode();
        } catch (exitCode) {
            // exitCode is 6
        }
    }
}
```

### 7: Type check error {#7}

If an argument to a primitive is of an incorrect value type or there is any other mismatch in types during the [compute phase](#compute), an error with exit code $7$ is thrown: `Type check error`.

```tact
// The actual returned value type doesn't match the declared one
asm fun typeCheckError(): map<Int, Int> { 42 PUSHINT }

contract VibeCheck {
    receive("I solemnly swear that I'm up to no good") {
        try {
            // The 0th index doesn't exist
            typeCheckError().get(0)!!;
        } catch (exitCode) {
            // exitCode is 7
        }
    }
}
```

### 8: Cell overflow {#8}

From the [Cells, Builders and Slices page](/book/cells#cells) of the Book:

> [`Cell{:tact}`][cell] is a [primitive][p] and a data structure, which [ordinarily](/book/cells#cells-kinds) consists of up to 1023 continuously laid out bits and up to 4 references (refs) to other cells.

To construct a [`Cell{:tact}`][cell], a [`Builder{:tact}`][builder] is used. If you try to store more than 1023 bits of data or more than 4 references to other cells, an error with exit code $8$ is thrown: `Cell overflow`.

This error can be triggered by [manual construction](/book/cells#cnp-manually) of the cells via [relevant `.storeSomething()` methods](/ref/core-cells#builder) or when [using structs and Messages and their convenience methods](/book/cells#cnp-structs).

```tact
// Too many bits
try {
    let data = beginCell()
        .storeInt(0, 250)
        .storeInt(0, 250)
        .storeInt(0, 250)
        .storeInt(0, 250)
        .storeInt(0, 24) // 1024 bits!
        .endCell();
} catch (exitCode) {
    // exitCode is 8
}

// Too many refs
try {
    let data = beginCell()
        .storeRef(emptyCell())
        .storeRef(emptyCell())
        .storeRef(emptyCell())
        .storeRef(emptyCell())
        .storeRef(emptyCell()) // 5 refs!
        .endCell();
} catch (exitCode) {
    // exitCode is 8
}
```

### 9: Cell underflow {#9}

From the [Cells, Builders and Slices page](/book/cells#cells) of the Book:

> `Cell{:tact}` is a [primitive][p] and a data structure, which [ordinarily](/book/cells#cells-kinds) consists of up to 1023 continuously laid-out bits and up to 4 references (refs) to other cells.

To parse a [`Cell{:tact}`][cell], a [`Slice{:tact}`][slice] is used. If you try to load more data or references than a `Slice{:tact}` contains, an error with exit code 9 is thrown: `Cell underflow`.

The most common cause of this error is a mismatch between the expected and actual memory layouts of the cells, so it's recommended to [use structs and Messages for parsing](/book/cells#cnp-structs) the cells instead of [manual parsing](/book/cells#cnp-manually) via [relevant `.loadSomething()` methods](/ref/core-cells#slice).

```tact
// Too few bits
try {
    emptySlice().loadInt(1); // 0 bits!
} catch (exitCode) {
    // exitCode is 9
}

// Too few refs
try {
    emptySlice().loadRef(); // 0 refs!
} catch (exitCode) {
    // exitCode is 9
}
```

### 10: Dictionary error {#10}

In Tact, the [`map<K, V>{:tact}`](/book/maps) type is an abstraction over the ["hash" map dictionaries of TVM](/book/maps#low-level-representation).

If there is incorrect manipulation of dictionaries, such as improper assumptions about their memory layout, an error with exit code $10$ is thrown: `Dictionary error`. Note that Tact prevents you from getting this error unless you perform [TVM assembly](https://docs.ton.org/develop/fift/fift-and-tvm-assembly) work yourself:

```tact
/// Pre-computed Int to Int dictionary with two entries — 0: 0 and 1: 1
const cellWithDictIntInt: Cell = cell("te6cckEBBAEAUAABAcABAgPQCAIDAEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMLMbT1U=");

/// Tries to preload a dictionary from a Slice as a map<Int, Cell>
asm fun toMapIntCell(x: Slice): map<Int, Cell> { PLDDICT }

contract DictPic {
    receive("I solemnly swear that I'm up to no good") {
        try {
            // The Int to Int dictionary is being misinterpreted as a map<Int, Cell>
            let m: map<Int, Cell> = toMapIntCell(cellWithDictIntInt.beginParse());

            // And the error happens only when we touch it
            m.get(0)!!;
        } catch (exitCode) {
            // exitCode is 10
        }
    }
}
```

### 11: "Unknown" error {#11}

Described in the [TVM][tvm] docs as "Unknown error, may be thrown by user programs," although most commonly used for problems with queuing a message send or problems with [get-methods](https://docs.ton.org/develop/smart-contracts/guidelines/get-methods).

```tact
try {
    // Unlike sendRawMessage which uses SENDRAWMSG, this one uses SENDMSG,
    // and therefore fails in Compute phase when the message is ill-formed
    sendRawMessageReturnForwardFee(emptyCell(), 0);
} catch (exitCode) {
    // exitCode is 11
}
```

### 12: Fatal error {#12}

Fatal error. Thrown by TVM in situations deemed impossible.

### 13: Out of gas error {#13}

If there isn't enough gas to complete computations in the [compute phase](#compute), an error with exit code $13$ is thrown: `Out of gas error`.

However, this code isn't immediately shown as is — instead, the bitwise NOT operation is applied, changing the value from $13$ to $-14$. Only then is the code displayed.

This is done to prevent the resulting code ($-14$) from being produced artificially in user contracts, as all functions that can [throw an exit code](/ref/core-debug) can only specify integers in the range from $0$ to $65535$ inclusive.

```tact
try {
    repeat (pow(2, 31) - 1) {}
} catch (exitCode) {
    // exitCode is -14
}
```

### -14: Out of gas error {#-14}

See [exit code 13](#13).

### 14: Virtualization error {#14}

Virtualization error related to [pruned branch cells](/book/cells#cells-kinds). Reserved but never thrown.

## Action phase {#action}

The [action phase][a] is processed after the successful execution of the [compute phase](#compute). It attempts to perform the actions stored in the action list by [TVM][tvm] during the compute phase.

Some actions may fail during processing, in which case those actions may be skipped or the whole transaction may revert depending on the mode of actions. The code indicating the resulting state of the [action phase][a] is called a _result code_. Since it is also a 32-bit signed integer that essentially serves the same purpose as the _exit code_ of the [compute phase](#compute), it is common to call the result code an exit code as well.

### 32: Action list is invalid {#32}

If the list of actions contains [exotic cells](/book/cells#cells-kinds), an action entry cell does not have references, or some action entry cell cannot be parsed, an error with exit code 32 is thrown: `Action list is invalid`.

:::note

  Aside from this exit code, there is a boolean flag `valid`, which you can find under `description.actionPhase.valid` in the transaction results when working with [Sandbox and Blueprint](#blueprint). A transaction can set this flag to `false` even when there is some other exit code thrown from the action phase.

:::

### 33: Action list is too long {#33}

If there are more than 255 actions queued for execution, the [action phase](#action) will throw an error with an exit code 33: `Action list is too long`.

```tact
// For example, let's attempt to queue reservation of a specific amount of nanoToncoins
// This won't fail in the compute phase, but will result in exit code 33 in the action phase
repeat (256) {
    nativeReserve(ton("0.001"), ReserveAtMost);
}
```

### 34: Invalid or unsupported action {#34}

There are only four supported actions at the moment: changing the contract code, sending a message, reserving a specific amount of [nanoToncoins](/book/integers#nanotoncoin), and changing the library cell. If there is any issue with the specified action (invalid message, unsupported action, etc.), an error with exit code $34$ is thrown: `Invalid or unsupported action`.

```tact
// For example, let's try to send an ill-formed message:
sendRawMessage(emptyCell(), 0); // won't fail in the compute phase,
                                   // but will result in exit code 34 in the Action phase
```

### 35: Invalid source address in outbound message {#35}

If the source address in the outbound message is not equal to [`addr_none`](https://docs.ton.org/develop/data-formats/msg-tlb#addr_none00) or to the address of the contract that initiated this message, an error with exit code $35$ is thrown: `Invalid source address in outbound message`.

### 36: Invalid destination address in outbound message {#36}

If the destination address in the outbound message is invalid, e.g., it does not conform to the relevant [TL-B][tlb] schemas, contains an unknown workchain ID, or has an invalid length for the given workchain, an error with exit code $36$ is thrown: `Invalid destination address in outbound message`.

:::note

  If the [optional flag +2](/book/message-mode#optional-flags) is set, this error won't be thrown, and the given message won't be sent.

:::

### 37: Not enough Toncoin {#37}

If all funds of the inbound message with [base mode 64](/book/message-mode#base-modes) set have already been consumed and there are not enough funds to pay for the failed action, or the [TL-B][tlb] layout of the provided value ([`CurrencyCollection`](https://docs.ton.org/develop/data-formats/msg-tlb#currencycollection)) is invalid, or there are not enough funds to pay [forward fees](https://docs.ton.org/develop/smart-contracts/guidelines/processing) or not enough funds after deducting fees, an error with exit code $37$ is thrown: `Not enough Toncoin`.

:::note

  If the [optional flag +2](/book/message-mode#optional-flags) is set, this error won't be thrown and the given message won't be sent.

:::

### 38: Not enough extra currencies {#38}

Besides the native currency, Toncoin, TON Blockchain supports up to $2^{32}$ extra currencies. They differ from creating new [Jettons](/cookbook/jettons) because extra currencies are natively supported — one can potentially just specify an extra [`HashmapE`](https://docs.ton.org/develop/data-formats/tl-b-types#hashmap) of extra currency amounts in addition to the Toncoin amount in the internal message to another contract. Unlike Jettons, extra currencies can only be stored and transferred and do not have any other functionality.

At the moment, **there are no extra currencies** on TON Blockchain, but the exit code $38$ for cases when there is not enough extra currency to send the specified amount is already reserved: `Not enough extra currencies`.

:::note[Useful links:]

  [Extra currencies](https://docs.ton.org/develop/dapps/defi/coins) in TON Docs.\
  [Extra currency mining](https://docs.ton.org/develop/research-and-development/minter-flow) in TON Docs.

:::

### 39: Outbound message doesn't fit into a cell {#39}

When processing the message, TON Blockchain tries to pack it according to the [relevant TL-B schemas](https://docs.ton.org/develop/data-formats/msg-tlb), and if it cannot, an error with exit code $39$ is thrown: `Outbound message doesn't fit into a cell`.

:::note

  If attempts at sending the message fail multiple times and the [optional flag +2](/book/message-mode#optional-flags) is set, this error won't be thrown and the given message won't be sent.

:::

### 40: Cannot process a message {#40}

If there are not enough funds to process all the cells in a message, the message is too large, or its Merkle depth is too big, an error with exit code $40$ is thrown: `Cannot process a message`.

:::note

  If the [optional flag +2](/book/message-mode#optional-flags) is set, this error won't be thrown and the given message won't be sent.

:::

### 41: Library reference is null {#41}

If a library reference is required during a library change action but is null, an error with exit code $41$ is thrown: `Library reference is null`.

### 42: Library change action error {#42}

If there's an error during an attempt at a library change action, an error with exit code $42$ is thrown: `Library change action error`.

### 43: Library limits exceeded {#43}

If the maximum number of cells in the library is exceeded or the maximum depth of the Merkle tree is exceeded, an error with exit code $43$ is thrown: `Library limits exceeded`.

### 50: Account state size exceeded limits {#50}

If the account state (contract storage, essentially) exceeds any of the limits specified in [config param 43 of TON Blockchain](https://docs.ton.org/develop/howto/blockchain-configs#param-43) by the end of the [action phase](#action), an error with exit code $50$ is thrown: `Account state size exceeded limits`.

If the configuration is absent, the default values are:

* `max_msg_bits` is equal to $2^{21}$ — maximum message size in bits.
* `max_msg_cells` is equal to $2^{13}$ — maximum number of [cells][cell] a message can occupy.
* `max_library_cells` is equal to $1000$ — maximum number of [cells][cell] that can be used as [library reference cells](/book/cells#cells-kinds).
* `max_vm_data_depth` is equal to $2^{9}$ — maximum [cells][cell] [depth](/book/cells#cells-representation) in messages and account state.
* `ext_msg_limits.max_size` is equal to $65535$ — maximum external message size in bits.
* `ext_msg_limits.max_depth` is equal to $2^{9}$ — maximum external message [depth](/book/cells#cells-representation).
* `max_acc_state_cells` is equal to $2^{16}$ — maximum number of [cells][cell] that an account state can occupy.
* `max_acc_state_bits` is equal to $2^{16} \times 1023$ — maximum account state size in bits.
* `max_acc_public_libraries` is equal to $2^{8}$ — maximum number of [library reference cells](/book/cells#cells-kinds) that an account state can use on the masterchain.
* `defer_out_queue_size_limit` is equal to $2^{8}$ — maximum number of outbound messages to be queued (regarding validators and collators).

## Tact compiler

Tact utilizes exit codes from $128$ to $255$. Note that exit codes used by Tact indicate contract errors, which can occur when using Tact-generated code and are therefore thrown in the transaction's [compute phase](#compute), not during compilation.

### 128: Null reference exception {#128}

If there is a non-null assertion, such as the [`!!{:tact}`](/book/operators#unary-non-null-assert) operator, and the checked value is [`null{:tact}`](/book/optionals), an error with exit code $128$ is thrown: `Null reference exception`.

This behavior can be modified by setting the [`nullChecks`](/book/config#safety-nullchecks) option to `false`, which will disable runtime null checks and would allow to save some gas. However, it is recommended to use it only for well-tested contracts, as it can lead to less recognizable type errors reported by TVM.

```tact
let gotcha: String? = null;

try {
    // Asserting that the value isn't null, which isn't the case!
    dump(gotcha!!);
} catch (exitCode) {
    // exitCode is 128
}
```

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 128 with the `TactExitCodeNullReferenceException` [constant][const].

### 129: Invalid serialization prefix {#129}

If there is an attempt to parse (deserialize) a [`Cell{:tact}`][cell] or [`Slice{:tact}`][slice] into a [message struct][message] and the parsed opcode prefix doesn't match the expected target one, an error with exit code $129$ is thrown: `Invalid serialization prefix`.

Thus, this error can occur whenever there is an opcode mismatch when using either of the following functions:

1. [`Message.fromCell{:tact}`](/ref/core-cells#messagefromcell)
2. [`Message.fromSlice(){:tact}`](/ref/core-cells#messagefromslice)

```tact
fun example() {
    // This cell contains a 32-bit opcode prefix (0x00000001)
    let cellOne = MsgOne {}.toCell();

    try {
        // This is a failed attempt to parse one message that has an opcode of 1 (0x00000001)
        // from a Cell with another message that has an opcode of 2 (0x00000002)
        let msgTwo = MsgTwo.fromCell(cellOne);
        dump(msgTwo.toCell());
    } catch (exitCode) {
        // exitCode is 129
    }
}

// An empty message struct with an opcode of 1 (0x00000001)
message(1) MsgOne {}

// An empty message struct with an opcode of 2 (0x00000002)
message(2) MsgTwo {}
```

Additionally, this error can happen if one hijacks the contract code before deployment and changes the opcodes of the [message structs][message] expected to be received in the contract.

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 129 with the `TactExitCodeInvalidSerializationPrefix` [constant][const].

### 130: Invalid incoming message {#130}

If the received internal or external message is not handled by the contract, an error with exit code $130$ is thrown: `Invalid incoming message`. It usually happens when the contract does not have a receiver for the particular message and its opcode prefix: a 32-bit integer header.

Consider the following contract:

```tact
import "@stdlib/deploy";

contract Dummy with Deployable {}
```

If you try to send any message except for [`Deploy{:tact}`](/ref/stdlib-deploy#deploy), provided by [`@stdlib/deploy`](/ref/stdlib-deploy), the contract will not have a receiver for it and thus will throw an error with exit code $130$.

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 130 with the `TactExitCodeInvalidIncomingMessage` [constant][const].

### 131: Constraints error {#131}

Constraints error. Reserved, but never thrown.

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 131 with the `TactExitCodeConstraintsError` [constant][const].

### 132: Access denied {#132}

If you use the [`Ownable{:tact}`](/ref/stdlib-ownable#ownable) [trait][trait] from the [`@stdlib/ownable`](/ref/stdlib-ownable) library, the helper function `requireOwner(){:tact}` provided by it will throw an error with exit code $132$ if the sender of the inbound message does not match the specified owner: `Access denied`.

```tact
import "@stdlib/ownable";

contract Hal9k with Ownable {
    owner: Address;

    init(owner: Address) {
        self.owner = owner; // set the owner address upon deployment
    }

    receive("I'm sorry Dave, I'm afraid I can't do that.") {
        // Checks that the message sender's address equals the owner address,
        // and if not — throws an error with exit code 132.
        self.requireOwner();

        // ... you do you ...
    }
}
```

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 132 with the `TactExitCodeAccessDenied` [constant][const].

### 133: Contract stopped {#133}

A message has been sent to a "stopped" contract: a contract that inherits the [`Stoppable{:tact}`](/ref/stdlib-stoppable#stoppable) trait and has the `self.stopped{:tact}` flag set to `true{:tact}`.

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 133 with the `ContractStopped` [constant][const].

### 134: Invalid argument {#134}

If there is an invalid or unexpected argument value, an error with exit code $134$ is thrown: `Invalid argument`.

Here are some of the functions in Tact which can throw an error with this exit code:

1. [`Int.toFloatString(digits){:tact}`](/ref/core-strings#inttofloatstring): if `digits` is not in the interval $0 < digits < 78$.

2. [`String.fromBase64(){:tact}`](/ref/core-strings#stringfrombase64) and [`Slice.fromBase64(){:tact}`](/ref/core-cells#slicefrombase64): if the given [`String{:tact}`][p] or [`Slice{:tact}`][slice] contains non-Base64 characters.

```tact
try {
    // 0 is the code of NUL in ASCII, and it is not valid Base64
    let code: Slice = beginCell().storeUint(0, 8).asSlice().fromBase64();
} catch (exitCode) {
    // exitCode is 134
}
```

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 134 with the `TactExitCodeInvalidArgument` [constant][const].

### 135: Code of a contract was not found {#135}

If the code of the contract is missing or does not match the one saved in TypeScript wrappers, an error with exit code $135$ will be thrown: `Code of a contract was not found`.

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 135 with the `TactExitCodeContractCodeNotFound` [constant][const].

### 136: Invalid standard address {#136}

A value of type [`Address{:tact}`][p] is considered a valid internal standard address if:

* It occupies $267$ bits: $3$ bits for its tag prefix, $8$ bits for the [chain ID](https://docs.ton.org/learn/overviews/addresses#workchain-id), and $256$ bits for the [account ID](https://docs.ton.org/learn/overviews/addresses#account-id).
* Its prefix is `0b100`, meaning it's an [`addr_std` in TL-B notation](https://docs.ton.org/v3/documentation/data-formats/tlb/msg-tlb#addr_std10) with no optional data.

Such checks are currently only performed in the [`Slice.asAddress(){:tact}`](/ref/core-cells#sliceasaddress) function. If any of the above is false, the function throws an error with exit code $136$: `Invalid standard address`.

```tact
let basechainID = 0;
let addrSlice = beginCell()
    .storeUint(0b10_1, 3) // unsupported prefix!
    .storeInt(basechainID, 8) // chain ID 0
    .storeUint(0, 42) // and a wrong size of the account ID!
    .asSlice();

try {
    // The tag prefix and account ID are both incorrect
    dump(addrSlice.asAddress(basechainID));
} catch (exitCode) {
    // exitCode is 136
}
```

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 136 with the `TactExitCodeInvalidStandardAddress` [constant][const].

### 137: Masterchain support is not enabled for this contract {#137}

<Badge text="Removed since Tact 1.6" variant="tip" size="medium"/><p/>

Prior to removal, any attempts to point to the masterchain (ID $-1$) or otherwise interact with it without enabling masterchain support threw an exception with exit code $137$: `Masterchain support is not enabled for this contract`.

```tact
let masterchainID = -1;

try {
    // Zero address in masterchain without the config option set
    dump(newAddress(masterchainID, 0));
} catch (exitCode) {
    // exitCode is 137
}
```

### 138: Not a basechain address {#138}

<Badge text="Available since Tact 1.6.3" variant="tip" size="medium"/><p/>

The value of type [`Address{:tact}`][p] belongs to a basechain, when its [chain ID](https://docs.ton.org/learn/overviews/addresses#workchain-id) is equal to 0.

Such check is currently only performed in the [`forceBasechain(){:tact}`](/ref/core-addresses#forcebasechain) function. If the address does not belong to a basechain, i.e., its chain ID isn't 0, the function throws an error with exit code 138: `Not a basechain address`.

```tact
let someBasechainAddress: Address =
    newAddress(0, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);

let someMasterchainAddress: Address =
    newAddress(-1, 0x83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8);

// Does not throw because the chain ID is 0
forceBasechain(someBasechainAddress);

try {
    // Throws because the chain ID is -1 (masterchain)
    forceBasechain(someMasterchainAddress);
} catch (exitCode) {
    // exitCode is 138
}
```

<Badge text="Available since Tact 1.6.6" variant="tip" size="medium"/> Access this exit code value 138 with the `TactExitCodeNotBasechainAddress` [constant][const].

[p]: /book/types#primitive-types
[trait]: /book/types/#traits
[cell]: /book/cells
[builder]: /book/cells#builders
[slice]: /book/cells#slices
[message]: /book/structs-and-messages#messages
[const]: /book/constants

[tlb]: https://docs.ton.org/develop/data-formats/tl-b-language
[tvm]: https://docs.ton.org/learn/tvm-instructions/tvm-overview
[bp]: https://github.com/ton-org/blueprint
[sb]: https://github.com/ton-org/sandbox
[jest]: https://jestjs.io
