Skip to content

No Contract State Diff or Transaction History Command #17

Description

@Nanle-code

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.

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions