---
eip: 3155
label: EIP-3155
title: EVM trace specification
status: Last Call
type: Standards Track
category: Interface
created: 2020-12-07
official: https://eips.ethereum.org/EIPS/eip-3155
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3155.md
canonical: https://eips.huatuo.xyz/eip-3155/
lang: en
tldr: A common JSON-lines format for step-by-step EVM execution traces, so the output of different clients can be diffed directly for debugging and differential fuzzing.
tags: [evm, tracing, debugging, testing, clients]
---

# EIP-3155: EVM trace specification

> A JSON format for EVM traces

**TL;DR:** A common JSON-lines format for step-by-step EVM execution traces, so the output of different clients can be diffed directly for debugging and differential fuzzing.

## What problem does it solve?

To find consensus bugs, client developers run the same state test or transaction through several EVM implementations and compare what happens at every step. Geth, Besu, Nethermind and OpenEthereum each had a tool that printed such traces in a roughly common JSON format, but the format was never precisely defined. Small differences (null vs empty arrays, decimal vs hex numbers, field order) made automated comparison unreliable.

EIP-3155 writes the format down, settles the corner cases, and gives sample output. With every client emitting identical lines, a **differential fuzzer** can feed random inputs to all EVMs and flag the first step where they disagree, which also helps diagnose chain splits quickly.

## How it works

The client under test prints **one JSON object per executed opcode**, then one **summary** object at the end.

Required per-step fields:

| Field | Type | Meaning |
| --- | --- | --- |
| `pc` | number | Program counter |
| `op` | number | Opcode byte |
| `gas` | hex | Gas left *before* this op |
| `gasCost` | hex | Cost of this op |
| `memSize` | number | Memory size |
| `stack` | array of hex | Stack *before* this op |
| `depth` | number | Call depth |
| `returnData` | hex string | Data returned by the last call |
| `refund` | number | Global gas refund counter |

Optional: `opName`, `error`, `memory`, `storage`. Arrays must be `[]`, never `null`. `memSize` is always present even if memory is not traced, and fields should appear in the listed order. Clients should allow storage tracing to be turned off.

The summary line must contain `stateRoot`, `output`, `gasUsed` and `pass`, and may include `time` (nanoseconds) and `fork`.

## Sample code

Output from Besu's `evmtool`, as given in the spec (trimmed):

```bash
evmtool --code 0x604080536040604055604060006040600060025afa6040f3
```

```json
{"pc":0,"op":96,"gas":"0x2540be400","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
{"pc":2,"op":128,"gas":"0x2540be3fd","gasCost":"0x3","memSize":0,"stack":["0x40"],"depth":1,"refund":0,"opName":"DUP1"}
{"pc":3,"op":83,"gas":"0x2540be3fa","gasCost":"0xc","memSize":0,"stack":["0x40","0x40"],"depth":1,"refund":0,"opName":"MSTORE8"}
{"stateRoot":"0x8fa0dcc7f1d2383c89e5737c2843632db881c0946e80b71fe7175365e6538797","output":"0x40","gasUsed":"0x515c","pass":true,"fork":"Istanbul"}
```

Finding the first divergence between two clients' traces (TypeScript, Node):

```ts
import { readFileSync } from "node:fs";

const KEYS = ["pc", "op", "gas", "gasCost", "stack", "depth"];
const load = (f: string) => readFileSync(f, "utf8").trim().split("\n").map((l) => JSON.parse(l));
const [a, b] = [load("geth.jsonl"), load("besu.jsonl")];

const i = a.findIndex((s, n) => KEYS.some((k) => JSON.stringify(s[k]) !== JSON.stringify(b[n]?.[k])));
console.log(i === -1 ? "traces match" : { step: i, a: a[i], b: b[i] });
```

## Things to know

- Status is **Last Call**: the text may still change before becoming Final.
- This is a tooling format, not a consensus change. Clients are free not to implement it, but those that do can join cross-client fuzzing.
- Tracing is expensive. Exposing trace endpoints publicly can be a denial-of-service vector, so keep them behind a separate flag.
- The spec has small inconsistencies: `memory` is described as an array of hex strings while the examples print one hex string, and the summary example shows `pass` as the string `"true"` in one place and a boolean in another. Compare semantically rather than byte-for-byte where these differ.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-3155
