Skip to main content
Export debugging data, such as state snapshots and memory dumps, from the currently active session.

Usage

erst export [flags]
erst export decode-memory [flags]

Description

The export command allows you to extract and save debugging data from an active session for:
  • Offline analysis
  • Sharing with team members
  • Integration with other tools
  • Creating reproducible test fixtures
  • Memory forensics
You must run erst debug <tx-hash> first to create an active session before using this command.

Subcommands

export

Export the current session’s ledger state and optionally WASM linear memory to a JSON snapshot file.

Flags

--snapshot
string
required
Output file for JSON snapshotThe snapshot will contain all ledger entries accessed during the transaction.
--include-memory
boolean
default:"false"
Include WASM linear memory dump from simulation responseOnly available if the simulator was configured to capture memory.

Examples

erst debug abc123...def
erst export --snapshot state.json

Output

Snapshot exported to state.json (127 entries)
With --include-memory:
Snapshot exported to state.json (127 entries)
Included linear memory dump: 65536 bytes (base64)

Snapshot format

The exported JSON file contains:
{
  "ledger_entries": {
    "<key1>": "<xdr-value1>",
    "<key2>": "<xdr-value2>",
    ...
  },
  "linear_memory": "<base64-encoded-memory>"
}
  • ledger_entries: Map of ledger keys to XDR-encoded values
  • linear_memory: Base64-encoded WASM memory dump (if --include-memory)

decode-memory

Decode and display a hexdump of the linear memory from a snapshot file.

Flags

--snapshot
string
required
Snapshot file that contains linear memory
--offset
int
default:"0"
Start offset in bytesMust be >= 0 and within memory bounds.
--length
int
default:"256"
Number of bytes to printMust be > 0.

Examples

erst export decode-memory --snapshot state.json

Output format

Displays a hexdump with ASCII representation:
Linear memory segment [0:256] (256 bytes)
0x00000000  00 00 00 00 01 00 00 00  48 65 6c 6c 6f 00 00 00  |........Hello...|
0x00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0x00000020  57 6f 72 6c 64 00 00 00  00 00 00 00 03 00 00 00  |World...........|
0x00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
...
Format:
  • Address: Hexadecimal offset
  • Hex bytes: Up to 16 bytes per line
  • ASCII: Printable characters (. for non-printable)

Use cases

Create test fixtures

Export ledger state for unit tests:
# Debug a transaction
erst debug abc123...def

# Export state
erst export --snapshot fixtures/test_state.json

# Use in tests
const state = require('./fixtures/test_state.json');

Offline debugging

Export data for analysis without network:
# Online: export session data
erst debug abc123...def --network mainnet
erst export --snapshot mainnet_state.json --include-memory

# Offline: analyze locally
erst export decode-memory --snapshot mainnet_state.json

Share debugging context

Share exact ledger state with team:
# Export state
erst debug abc123...def
erst export --snapshot bug_reproduction.json

# Team member loads it
erst debug --snapshot bug_reproduction.json

Memory forensics

Analyze WASM memory for debugging:
# Export with memory
erst debug abc123...def
erst export --snapshot crash.json --include-memory

# Examine stack region
erst export decode-memory --snapshot crash.json --offset 65536 --length 1024

# Check heap
erst export decode-memory --snapshot crash.json --offset 1048576 --length 4096

Compare states

Export before/after snapshots:
# Before
erst debug tx_before --snapshot before.json

# After
erst debug tx_after --snapshot after.json

# Diff the snapshots
diff <(jq -S . before.json) <(jq -S . after.json)

Snapshot files

Size

Snapshot file sizes vary based on:
  • Ledger entries: Typically 10-500 KB
  • Linear memory: Adds 64 KB - 4 MB (if included)

Compression

For large snapshots, consider compression:
# Export
erst export --snapshot state.json --include-memory

# Compress
gzip state.json

# Later: decompress and use
gunzip state.json.gz
erst export decode-memory --snapshot state.json

Portability

Snapshots are portable across:
  • Different machines
  • Different OS platforms
  • Different Erst versions (same schema)
Snapshots use XDR encoding for ledger entries, making them network-agnostic and version-stable.

Error handling

No active session

Error: no active session. Run 'erst debug <tx-hash>' first
Solution: Debug a transaction first:
erst debug abc123...def
erst export --snapshot state.json

No memory dump available

Warning: Simulator response does not include a linear memory dump.
Snapshot exported to state.json (127 entries)
Cause: Simulator wasn’t configured to capture memory. Solution: This is expected - memory dumps are optional. The snapshot still contains all ledger state.

Invalid offset

Error: offset 100000 out of bounds for memory size 65536
Solution: Use a valid offset:
# Check memory size first
erst export decode-memory --snapshot state.json --offset 0 --length 16
  • debug - Create sessions for export
  • session - Manage saved sessions
  • trace - Analyze execution traces