state_server is a REST API for managing persistent Merkle tries used by HDP injected state workflows.
It is different from HDP Server API:
- State Server: injected-state trie service (
/create_trie,/read,/write,/get_state_proofs). - HDP Server API: orchestrated HDP task execution service (
/tasks, task status, task outputs).
What it provides
- Create and manage multiple tries by label
- Read and write key/value pairs
- Return trie roots for specific states
- Generate inclusion/non-inclusion and update proofs
- Persist trie data in SQLite-backed storage
Run the server
--host(default0.0.0.0)--port(default3000)--db_root_path(defaultdb)
Core endpoints
POST /create_trieGET /readPOST /writePOST /get_state_proofsGET /get_trie_root_node_idx
Endpoint behavior
POST /create_trie: create a trie label with initial keys/valuesGET /read: read a key for a specific trie rootPOST /write: upsert key/value and return the new trie rootPOST /get_state_proofs: generate proof payloads for read/write actionsGET /get_trie_root_node_idx: resolve the internal node index for a root
Quick examples
Create trie:HDP integration
In HDP flows, injected-state handlers use the state server during dry/fetch phases, and the resulting proofs are consumed during sound-run.End-to-end usage with HDP
This is the practical flow most teams use:- Start
state_server - Set
INJECTED_STATE_BASE_URL - Run
dry-runwith--injected_state - Run
fetch-proofs(state proofs are pulled from state server) - Run
sound-runwith the same--injected_statefile
dry-runrecords injected-state read/write actions,fetch-proofsconverts those actions into state proof payloads,sound-runverifies those proofs before your Cairo logic consumes the values.
Cairo-side usage in modules
In your module, usehdp.injected_state helpers:
Working example to copy from
- Module: examples/injected_state/src/lib.cairo
- Run script: examples/injected_state/run.sh
- Injected state input: examples/injected_state/injected_state.json

