Soroban Smart Contract Monitoring: What Developers Should Track in Production
You deployed your Soroban smart contract to mainnet. It is live, processing transactions, managing state. But how do you know if it is working correctly? How do you find out when something goes wrong before your users do?
What Can Go Wrong
Core Metrics to Track
1. Invocation Success Rate
The most fundamental metric. A healthy contract should have a 95%+ success rate. Failures below that indicate a bug, UI issue, or configuration problem.
2. Gas Consumption
Track average and P95 gas per invocation. A sudden spike usually indicates an inefficient code path, unexpectedly large storage entries, or a new usage pattern.
3. Error Types
| Error Type | Meaning |
|---|---|
| `InvokeHostFunctionFailed` | Contract execution reverted |
| `InsufficientBalance` | Caller lacks XLM for fees |
| `ExceededResourceLimit` | Transaction hit CPU/memory limits |
| `StorageEntryNotFound` | Missing storage entry |
4. Storage State
Track persistent, temporary, and instance storage entry counts and sizes. Storage has direct cost implications — entries that expire must be restored at additional cost.
5. Event Volume
If your contract emits events, monitor volume over time, events by topic, and gaps where events should be firing but are not.
Setting Up Monitoring
Using Stellar RPC Events
Poll the getEvents RPC method at regular intervals:
{
"jsonrpc": "2.0",
"id": 1,
"method": "getEvents",
"params": {
"startLedger": 61000000,
"filters": [{
"type": "contract",
"contractIds": ["YOUR_CONTRACT_ID"],
"topics": [["*"]]
}],
"pagination": { "limit": 100 }
}
}Alerting Rules
| Alert | Condition | Severity |
|---|---|---|
| **Success rate drop** | Below 90% over 1 hour | Critical |
| **No invocations** | Zero calls in 30 min (if normally active) | Warning |
| **Gas spike** | P95 gas 2x baseline | Warning |
| **Storage growth** | 10%+ increase in 24 hours | Info |
| **Error burst** | 5+ failures in 5 minutes | Critical |
Common Production Issues
TTL Expiration
Soroban storage entries have time-to-live values. If an entry expires, it must be restored before it can be read, causing unexpected failures. Monitor TTL values for critical entries.
Frontend Staleness
If your frontend caches contract state, users may submit transactions based on stale data. Monitor the delta between frontend state and actual contract state.
Tools
LumenQuery provides contract monitoring tools:
*Monitor your Soroban contracts in production with LumenQuery. Decoded calls, storage viewer, and event streaming — start free.*