Debug Playbook
1. Revert Decoding
1.1 Anatomy of a Revert
Type
Selector
Description
Example
1.2 Catching and Displaying Reverts in Hardhat
try {
await treasury.withdraw(1000);
} catch (error: any) {
console.log('Revert reason:', error.reason || error.message);
console.log('Full error data:', error.data || error.error?.data);
}1.3 Decoding Panic Codes
Panic Code
Description
Typical Cause
1.4 Advanced Revert Inspection with Hardhat Traces
1.5 Custom Error Decoding for Verified Contracts
2. Common Error Patterns on Somnia
Error Type
Cause
Fix
2.1 Example: Catching a Custom Error in Somnia Treasury Contract
2.2 Handling Complex Contract Interactions
2.3 Invalid ABI or Proxy Conflicts
3. Transaction Simulation
3.1 Fork Somnia Networks Locally
3.2 Using callStatic for Dry-Run Simulation
3.3 Using eth_call Manually
3.4 Impersonating Accounts for Privileged Actions
3.5 Snapshot and Rollback Control
3.6 Simulating On-Chain Transactions
3.7 Advanced Fork Testing with Foundry
3.8 Gas Profiling and Cost Analysis
3.9 Full Transaction Lifecycle Test
1
2
3
4
5
6
7
Last updated