Skip to content
14 changes: 12 additions & 2 deletions ecosystem/explorers/tonviewer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ At point **A** (`mintmachine.ton`), an external-in message initiates the operati

2. **Identify accounts**

- A — sender's wallet contract (`mintmachine.ton`).
- A — sender's wallet contract (mintmachine.ton).
- B — jetton wallet contract governed by the jetton master.

3. **Inspect messages**
Expand Down Expand Up @@ -126,7 +126,7 @@ The trace begins at point **A** (the user’s `mintmachine.ton` contract). An ex

2. **Identify accounts**

- A — user's `mintmachine.ton` account, sending the initial funds.
- A — user's mintmachine.ton account, sending the initial funds.
- B — user's jetton wallet.
- C — DEX jetton wallet.
- D — DEX smart contract executing the swap.
Expand Down Expand Up @@ -188,3 +188,13 @@ All transactions along the trace completed their phases without error, no warnin
5. **Find the failure point**

No failure point — the operation completed successfully.

## Debugging with retracer

Sometimes, reading messages and transaction phases is not enough.
A transaction may show _successful compute and action phases, exit codes of `0`, and no errors in messages_ — yet still produce no effect on-chain.

In such cases, you need to trace the **TVM execution path**.
[Retracer](https://retracer.ton.org/) lets you replay the transaction and inspect what happened inside the virtual machine.

See [Debugging with TVM Retracer](/guidebook/debug#debugging-with-tvm-retracer) for details.
40 changes: 34 additions & 6 deletions guidebook/debug.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Hands-on debugging"
---

import {Aside} from "/snippets/aside.jsx";
import { Aside } from "/snippets/aside.jsx";

<Aside>
This guide assumes you use [Blueprint](/ecosystem/blueprint/overview) with [`@ton/sandbox`](/ecosystem/blueprint/testing/reference). These are common tools for debugging smart contracts.
Expand Down Expand Up @@ -129,11 +129,19 @@ However, the slice has only **725** bits and **711** bits were already read, as

You should locate the `load_uint(64)` call that causes the issue and ensure enough bits are available or adjust the read width.

<Aside
type="warning"
>
Note, that TVM debug output is limited to
</Aside>
**TVM log limits**

The size of TVM debug output depends on the verbosity level:

| Level | Setting | Max size |
| ----- | :----------------------------------------------------------------------------: | :-------------------: |
| 0 | `none` | 256 bytes _(default)_ |
| 1–4 | `vm_logs` <br /> `vm_logs_location` <br /> `vm_logs_gas` <br /> `vm_logs_full` | 1 MB |
| 5 + | `vm_logs_verbose` and above | 32 MB |

When the output exceeds its limit, it is truncated **from the bottom** —
older entries are discarded, and only the most recent lines are kept.
Logs are **not rotated**.

## Explore the transaction tree

Expand All @@ -154,3 +162,23 @@ Two tools are commonly used:
- [TxTracer Sandbox](https://txtracer.ton.org/sandbox/) — requires a custom `@ton/sandbox` package; runs in your browser.

Also these tools allow you to explore each transaction separate logs.

## Debugging with TVM Retracer

Even when a contract executes successfully (exit code = `0`) with no errors, its actions may not produce the expected on-chain effect. [TVM Retracer](https://retracer.ton.org/) lets you replay the transaction and inspect VM-level execution.

### Scenarios for retracing

- All transaction phases complete without errors, yet the expected outcome is missing.
- An action is skipped, or a transfer does not reach its destination.
- You need a step-by-step view of how the TVM executed your contract logic.

### How to analyze a transaction

1. Obtain the transaction hash from a [blockchain explorer](/ecosystem/explorers/overview).
1. Open [TVM Retracer](https://retracer.ton.org/) and enter the transaction hash.
1. Review the execution:

- Inspect **Logs section** for executed instructions and exceptions.
- Examine **Actions cell (C5)** to review data passed between contracts.
- Check **message modes** — some modes can suppress errors, causing actions to be skipped.
3 changes: 3 additions & 0 deletions resources/dictionaries/custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ Reindexing
Relatedly
Reputational
Reth
Retracer
Revm
Ristretto
Rollup
Expand Down Expand Up @@ -506,6 +507,7 @@ minimalistic
minmax
mintable
mintless
mintmachine
misclick
misclicks
misconfiguration
Expand Down Expand Up @@ -594,6 +596,7 @@ relatedly
relayer
resharding
resynced
retracer
rollup
ruleset
runbooks
Expand Down