> For the complete documentation index, see [llms.txt](https://docs.megaeth.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.megaeth.com/mega-evme/tracing/overview.md).

# Overview

`mega-evme` can record detailed execution traces during EVM runs. Traces are useful for debugging reverts, analyzing gas consumption, and understanding call flow.

## Enabling Tracing

Add `--trace` to any command to enable tracing:

```bash
mega-evme run 0x60016000526001601ff3 --trace
```

By default, this uses the [opcode tracer](/mega-evme/tracing/opcode-tracer.md). Use `--tracer` to pick a different tracer.

## Tracers

| Tracer                                             | `--tracer` value                | Description                                                            |
| -------------------------------------------------- | ------------------------------- | ---------------------------------------------------------------------- |
| [Opcode](/mega-evme/tracing/opcode-tracer.md)      | `opcode` (default)              | Step-by-step opcode execution log with gas, stack, memory, and storage |
| [Call](/mega-evme/tracing/call-tracer.md)          | `call`                          | Nested call tree showing CALL/CREATE hierarchy, gas, and return data   |
| [Pre-State](/mega-evme/tracing/prestate-tracer.md) | `pre-state` (alias: `prestate`) | Account state accessed during execution, with optional diff mode       |

## Common Options

These flags apply to all tracers:

| Flag                    | Default  | Description                                         |
| ----------------------- | -------- | --------------------------------------------------- |
| `--trace`               | `false`  | Enable tracing                                      |
| `--trace.output <PATH>` | stdout   | Write trace output to a file instead of the console |
| `--tracer <TRACER>`     | `opcode` | Select which tracer to use                          |

## Output

Trace output is JSON. When `--trace.output` is not set, the trace is printed to stdout after the execution result. When `--trace.output` is set, the trace is written to the specified file and only the execution result appears on stdout.

```bash
# Trace to file
mega-evme run 0x60016000526001601ff3 \
  --trace --tracer opcode \
  --trace.output trace.json

# Trace to stdout (default)
mega-evme run 0x60016000526001601ff3 --trace
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.megaeth.com/mega-evme/tracing/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
