Overview
starforge contract inspect shows the current state of a contract instance, but there is no way to see how state changed over time, what transactions modified it, or to audit the history of invocations. For DeFi contracts on mainnet this is essential for debugging and auditing.
Resolution
Implement starforge contract history <contract_id> using Horizon's transaction history endpoint /accounts/{contract_id}/transactions?limit=200&order=desc combined with Soroban RPC's getTransaction to decode each transaction's footprint and state changes. For each transaction: parse the TransactionMeta XDR (v3 meta contains sorobanMeta.returnValue and events), decode the ledgerEntryChanges to extract before/after ScVal snapshots for each storage key. Display as a timeline with diffs: key "counter": 5 → 6. Implement starforge contract state-at <contract_id> --ledger <N> using getLedgerEntries with a specific ledger sequence. Cache fetched ledger entry data locally in ~/.starforge/cache/ with a TTL to avoid re-fetching immutable historical data. Export history as CSV or JSON for offline analysis.
Overview
starforge contract inspectshows the current state of a contract instance, but there is no way to see how state changed over time, what transactions modified it, or to audit the history of invocations. For DeFi contracts on mainnet this is essential for debugging and auditing.Resolution
Implement
starforge contract history <contract_id>using Horizon's transaction history endpoint/accounts/{contract_id}/transactions?limit=200&order=desccombined with Soroban RPC'sgetTransactionto decode each transaction's footprint and state changes. For each transaction: parse theTransactionMetaXDR (v3 meta containssorobanMeta.returnValueandevents), decode theledgerEntryChangesto extract before/afterScValsnapshots for each storage key. Display as a timeline with diffs:key "counter": 5 → 6. Implementstarforge contract state-at <contract_id> --ledger <N>usinggetLedgerEntrieswith a specific ledger sequence. Cache fetched ledger entry data locally in~/.starforge/cache/with a TTL to avoid re-fetching immutable historical data. Export history as CSV or JSON for offline analysis.