Skip to main content
JavaScript tracers let you create custom debugging logic to analyze EVM transactions on Sei. You can use them for more complex analysis than the built-in tracers support.
JavaScript tracers are disabled by default on Sei. Unlike upstream geth, Sei does not accept request-supplied JavaScript tracer source on debug_trace* endpoints unless a node operator explicitly opts in. To enable them, set trace_allow_js_tracers = true under the [evm] section of app.toml.This is a deliberate security hardening: a JavaScript tracer executes caller-supplied code in-process on the node, so it should only be enabled on trusted or private RPC nodes — never on public/default RPC infrastructure. Enabling trace_allow_js_tracers does not widen the native tracer allowlist (trace_allowed_tracers); the two settings are independent.If trace_allow_js_tracers is false (the default), any request supplying JavaScript tracer source to debug_traceCall, debug_traceTransaction, debug_traceBlockBy*, or debug_traceTransactionProfile is rejected before any tracer is constructed. If you only need standard analysis, prefer the built-in native tracers (callTracer, prestateTracer, flatCallTracer, 4byteTracer, noopTracer, muxTracer), which require no opt-in.

Interface overview

Every JavaScript tracer has this structure:

Core methods

step(log, db)

This method runs for each EVM opcode that executes. Put your main analysis logic here. Parameters:
  • log: The current execution context, with methods such as getPC(), op.toString(), and getCost()
  • db: The database interface to query state
Gas cost: Varies by tracer complexity

result(ctx, db)

This method runs at the end of execution and returns your analysis results. Parameters:
  • ctx: The execution context, with gasUsed and transaction information
  • db: The database interface for final queries

Advanced tracer examples

State change tracker

Track every state change in detail:

DeFi transaction analysis

Analyze complex DeFi transactions with multiple contract interactions:

Security analysis tracer

Detect suspicious patterns and potential vulnerabilities:

Gas optimization tracer

Identify expensive operations for gas optimization:

Performance optimization

Optimize your tracer code, and use timeouts in production. JavaScript tracers can slow down tracing significantly.

Memory-efficient patterns

Selective operation tracking

Configuration options

Basic configuration

Production settings

Practical integration examples

Smart contract debugger

DeFi analytics dashboard

Best practices

  1. Start simple: Begin with basic tracers before you add complexity.
  2. Limit data collection: Collect only the information that you need.
  3. Use efficient data structures: Prefer counters to arrays when possible.
  4. Set appropriate timeouts: Balance thoroughness with performance.
  5. Test incrementally: Validate tracers on simple transactions first.
  6. Handle errors gracefully: Include error handling in your tracers.

Common use cases

Gas profiling

Event extraction

If you have issues with JavaScript tracers, see the Troubleshooting guide for common solutions and debugging tips.