Contract State
Know what changed in any Stacks contract, when, and who changed it.
Every map and variable write from block 1, with the transaction that made it.
One key, one call, for any transaction:
That ALEX swap ran 22 calls between contracts and wrote two maps; the response shows one. A transaction id is enough.
Five event types cover what a contract stores and every call it makes. Values are Clarity 0x hex. Every type filters by contract, transaction and height; the rest are below. Filters: List events.
event_type | Tells you | Extra filters |
|---|---|---|
nested_contract_call | Who really uses a contract, including apps that route through another one, and calls that failed and were handled | functionName, caller, sender |
var_set | A setting or counter changed | varName |
map_set | An entry changed | map |
map_insert | A new position, listing or balance | map |
map_delete | An entry was removed | map |
Who made the call
Every call between contracts carries two principals.
| Field | Means |
|---|---|
contract_id | The contract called |
caller | Who made the call: Clarity's contract-caller |
sender | tx-sender at that moment. as-contract swaps it for the contract that used it |
At the ALEX drain, block 1,508,068, a vault called a fake token, which moved the vault's real tokens.
| Rows | Call | caller | sender |
|---|---|---|---|
| 21 | Vault calls the fake token's transfer-fixed | vault | vault |
| 14, 16, 18, 20 | Fake token moves aBTC, sBTC, ALEX and sUSDT | fake token | vault |
An unfamiliar caller with a vault as sender means that contract is moving the vault's tokens. The vault's own call looks normal alone.
Walk one map's writes to know what any key held after any transaction.
No print carries that write, and a node can't say which transaction set a key. For storage keys rather than named maps, read state writes.
State Writes
Every key a block wrote, in node order.
| Field | Means |
|---|---|
cursor | <block_height>:<ordinal> |
block_height, ordinal | The block, and the write's position in node order |
tx_index | null for block-level writes |
key | The chain's storage key |
value_hex | The new value |
GET /v1/index/state-writes;block_heightreads one block, not with a height range.- Self-hosted rows start where your node first sent the
state_writesobserver key.
The same rows stream with clock: "vm" through the checkpointed consumer.
A webhook fires on the same types once the block lands, whenever a vault's reserves change:
A subgraph takes map_set and var_set as sources; built from stored values, anyone can rebuild its rows.
The node patch is public; history is a six-week replay from block 1.
| Covered | Not covered |
|---|---|
| Values a contract stores, and calls between contracts | Every intermediate value in the code |
| Transactions that landed | Anything before it lands: it warns, it does not prevent. A transaction that fails outright leaves no rows |
| History from block 1, and who made each change | Something new about one key's current value: a node could always read that |
| Stored values, checkable against the block's state root | Calls between contracts: not committed on chain, so not provable |
Reads are metered like event rows (Keys and Billing), so scope by contract and map. Reading contract state and testing on it use the meters. A hosted webhook or subgraph on contract state needs the Contract state plan: $999 a month, with $100 of usage included. Upgrade from the credits page or the pricing page.
When the plan ends, hosted webhooks on contract state pause and hosted subgraphs on contract state stop. Nothing restarts on its own: resubscribe, then resume each webhook and redeploy each subgraph.
Hosted mainnet has rows from block 1; a self-hosted instance only from the block its node first recorded them.
Edit on GitHub