StateDiff
Complete state changes across all accounts during transaction execution. Primary output from debug_traceTransaction with prestateTracer.Overview
StateDiff captures all state modifications: balance changes, nonce increments, code deployments, and storage updates. Essential for state analysis and forensics.Type Definition
Usage
Creating State Diffs
Querying State Changes
prestateTracer Integration
Primary use case for StateDiff:Account Changes
Balance Changes
ETH transfers modify balances:Nonce Increments
Transaction execution increments sender nonce:Contract Deployment
Code deployment creates new contract:Storage Updates
Contract storage modifications:Analysis Patterns
Transaction Impact
Analyze full transaction impact:Gas Cost Estimation
Calculate state change costs:Forensics
Investigate suspicious transactions:API Reference
Constructors
StateDiff.from(accounts)- Create from Map/arrayStateDiff.from({ accounts })- Create from object
Methods
StateDiff.getAccount(diff, address)- Get account changesStateDiff.getAddresses(diff)- Get all modified addressesStateDiff.isEmpty(diff)- Check if state was modified
See Also
- StorageDiff - Storage slot changes
- MemoryDump - Memory snapshots
- Wei - ETH amounts
- Nonce - Transaction counters
- Address - Account addresses

