Exit codes
Each transaction on TON Blockchain comprises multiple phases. An exit code is a 32-bit signed integer that indicates whether the compute or action phase succeeded. When unsuccessful, it contains the exception code that occurred. Each exit code represents a specific exception or transaction outcome.
Exit code 0 indicates standard successful execution of the compute phase. Exit code 1 is reserved as an alternative success code but is not occurred. Any other exit code indicates that a specific exception has occurred and that the transaction was unsuccessful in some way, 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 FunC code and are therefore thrown in the transaction's compute phase and not during the compilation.
The range from 256 to 65535 is free for developer-defined exit codes.
While exit codes are 32-bit signed integers in TON, attempting to throw an exit code outside the 16-bit unsigned integer range (0-65535) will trigger an error with exit code 5. This intentionally prevents the artificial generation of specific exit codes like -14.
Table of exit codes
The following table lists exit codes with an origin (where it can occur) and a short description. The table doesn't list the exit codes from contracts. To see such exit codes, refer to the source code of the specific contract.
Exit code | Origin | Brief description |
---|---|---|
0 | Compute and action phases | Standard successful execution exit code. |
1 | Compute phase | Alternative successful execution exit code. Reserved, but doesn't occur. |
2 | Compute phase | Stack underflow. |
3 | Compute phase | Stack overflow. |
4 | Compute phase | Integer overflow. |
5 | Compute phase | Range check error: an integer is out of its expected range. |
6 | Compute phase | Invalid TVM opcode. |
7 | Compute phase | Type check error. |
8 | Compute phase | Cell overflow. |
9 | Compute phase | Cell underflow. |
10 | Compute phase | Dictionary error. |
11 | Compute phase | As described in TVM documentation: "Unknown error, may be thrown by user programs". |
12 | Compute phase | Fatal error thrown by TVM in unexpected situations. |
13 | Compute phase | Out of gas error. |
-14 | Compute phase | Equivalent to code 13. A negative value (see 13) prevents emulation. |
14 | Compute phase | VM virtualization error (reserved but unused). |
32 | Action phase | Action list is invalid. |
33 | Action phase | Action list is too long. |
34 | Action phase | Action is invalid or not supported. |
35 | Action phase | Invalid source address in outbound message. |
36 | Action phase | Invalid destination address in outbound message. |
37 | Action phase | Not enough Toncoin. |
38 | Action phase | Not enough extra currencies. |
39 | Action phase | Outbound message does not fit into a cell after rewriting. |
40 | Action phase | Cannot process a message — not enough funds, the message is too large, or its Merkle depth is too big. |
41 | Action phase | Library reference is null during library change action. |
42 | Action phase | Library change action error. |
43 | Action phase | Exceeded the maximum number of cells in the library or the maximum depth of the Merkle tree. |
50 | Action phase | Account state size exceeded limits. |
128 | Tact compiler (Compute phase) | Null reference exception. Configurable since Tact 1.6. |
129 | Tact compiler (Compute phase) | Invalid serialization prefix. |
130 | Tact compiler (Compute phase) | Invalid incoming message — there's no receiver for the opcode of the received message. |
131 | Tact compiler (Compute phase) | Constraints error. Reserved, but never thrown. |
132 | Tact compiler (Compute phase) | Access denied — someone other than the owner sent a message to the contract. |
133 | Tact compiler (Compute phase) | Contract stopped. Reserved, but never thrown. |
134 | Tact compiler (Compute phase) | Invalid argument. |
135 | Tact compiler (Compute phase) | Code of a contract was not found. |
136 | Tact compiler (Compute phase) | Invalid standard address. |
138 | Tact compiler (Compute phase) | Not a BaseChain address. |
The exit code 65535 (0xffff
) typically indicates the same issue as exit code 130
: an unrecognized message opcode. It is assigned manually when developing contracts rather than generated by TVM or the Tact compiler.
Compute phase
The TVM initialization and all computations occur during the compute phase. If this phase fails (resulting in an exit code other than 0 or 1), the transaction skips the action phase and proceeds to generate bounce messages for transactions initiated by inbound messages.
0: Normal termination
This exit (or result) code indicates a successful completion of the compute (or action) phase of the transaction.