Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ecosystem/explorers/tonviewer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
At point **A** (mintmachine.ton), an external-in message initiates the operation, instructing a jetton transfer.

2. **Identify accounts**

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

Expand Down Expand Up @@ -126,6 +127,7 @@
The trace begins at point **A** (the user’s `mintmachine.ton` contract). An external-in message initiates the swap attempt.

2. **Identify accounts**

- A — user's mintmachine.ton account, sending the initial funds.
- B — user's jetton wallet.
- C — DEX jetton wallet.
Expand Down Expand Up @@ -189,4 +191,12 @@

No failure point — the operation completed successfully.

## Debugging with retracer

Check failure on line 194 in ecosystem/explorers/tonviewer.mdx

View workflow job for this annotation

GitHub Actions / Spelling

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'retracer'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'retracer'?", "location": {"path": "ecosystem/explorers/tonviewer.mdx", "range": {"start": {"line": 194, "column": 19}}}, "severity": "ERROR"}

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.
44 changes: 36 additions & 8 deletions guidebook/debug.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## title: "Hands-on debugging"

---
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`. 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.
Loading