Overview
Thedebug namespace offers methods for debugging transactions, tracing execution, inspecting state, and diagnosing blockchain issues.
Transaction Tracing
debug_traceTransaction
Returns a detailed trace of a transaction’s execution.string
required
Transaction hash (32 bytes, hex encoded)
object
Trace configuration options
object
Execution trace with opcode-level details
debug_traceBlockByNumber
Traces all transactions in a block by block number.string
required
Block number (hex) or “latest”
object
Trace configuration (same as debug_traceTransaction)
array
Array of transaction traces for all transactions in the block
debug_traceBlockByHash
Traces all transactions in a block by block hash.string
required
Block hash (32 bytes, hex encoded)
object
Trace configuration (same as debug_traceTransaction)
debug_traceBlock
Traces all transactions in a raw block.string
required
RLP-encoded block data (hex)
object
Trace configuration
Block Inspection
debug_dumpBlock
Returns the state of all accounts at a given block.string
required
Block number (hex) or “latest”, “earliest”, “pending”
object
State dump containing all account data
debug_printBlock
Returns a human-readable representation of a block.number
required
Block number (decimal)
string
Pretty-printed block information
debug_getBlockRlp
Returns RLP-encoded block data.number
required
Block number (decimal)
string
RLP-encoded block (hex)
State Inspection
debug_storageRangeAt
Returns storage entries for a contract at a specific transaction.string
required
Block hash
number
required
Transaction index in block
string
required
Contract address
string
required
Starting storage key (hex)
number
required
Maximum number of entries to return
object
Storage range result
debug_preimage
Returns the preimage of a hash stored in the database.string
required
Hash (32 bytes, hex)
string
Preimage data (hex) or null if not found
debug_getModifiedAccountsByNumber
Returns accounts modified between two blocks.number
required
Start block number (decimal)
number
End block number (decimal, optional)
array
Array of addresses that were modified
debug_getModifiedAccountsByHash
Returns accounts modified between two blocks (by hash).string
required
Start block hash
string
End block hash (optional)
Bad Blocks
debug_getBadBlocks
Returns a list of recently rejected bad blocks.array
Array of bad block objects with rejection reasons
Chain Management
debug_setHead
Rewinds the blockchain to a specific block number.string
required
Block number to rewind to (hex)
debug_seedHash
Returns the seed hash used for PoW at a given block.number
required
Block number (decimal)
string
Seed hash (hex)
Database Operations
debug_chaindbProperty
Returns LevelDB properties.string
required
Property name (e.g., “leveldb.stats”)
string
Property value
debug_chaindbCompact
Triggers a database compaction.null
null on success
Database compaction can take significant time and resources. Run during low-traffic periods.
Usage Examples
JavaScript - Transaction Tracing
Python - State Inspection
Call Tracer Example
Performance Considerations
Best Practices
- Use timeouts: Always set reasonable timeouts for trace operations
- Disable unnecessary data: Use
disableStorage,disableMemory,disableStackto reduce overhead - Limit scope: Trace specific transactions rather than entire blocks when possible
- Cache results: Store trace results to avoid recomputation
- Use dedicated nodes: Run debug operations on separate nodes from production RPC
Enabling Debug APIs
To enable debug APIs on a Viction node:Common Use Cases
Transaction Debugging
Trace failed transactions to identify revert reasons and execution flow
Gas Optimization
Analyze opcode execution to optimize gas usage in smart contracts
State Analysis
Inspect contract storage and account states at specific blocks
Security Auditing
Trace contract interactions to verify security properties