> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sequencer Quickstart

> Run the VES sequencer, ingest a signed event, and read back an inclusion proof.

# Sequencer Quickstart

The sequencer orders events, commits them to Merkle roots, and anchors those commitments so anyone
can verify inclusion without trusting it. This gets one running and walks a single event through.

## Run it

```bash theme={null}
docker-compose up -d

curl http://localhost:8080/health     # process up
curl http://localhost:8080/ready      # + database connectivity
```

Authentication is **`Authorization: ApiKey <key>`**. A bootstrap admin key exists for local
development:

```bash theme={null}
curl -H "Authorization: ApiKey dev_admin_key" \
  "http://localhost:8080/api/v1/head?tenant_id=<uuid>&store_id=<uuid>"
```

<Warning>
  `dev_admin_key` is a development bootstrap credential. Replace it before anything reachable from
  outside your machine.
</Warning>

## 1. Register an agent key

Events are signed, so the sequencer needs the agent's public key first.

```bash theme={null}
curl -X POST http://localhost:8080/api/v1/agents/register \
  -H "Authorization: ApiKey $SEQ_API_KEY" \
  -H 'content-type: application/json' \
  -d '{ … }'
```

Keys are registered with **proof of possession** — the agent demonstrates it holds the private key
rather than merely asserting a public one. See `/api/v1/agents/keys`.

## 2. Ingest an event

```bash theme={null}
curl -X POST http://localhost:8080/api/v1/events/ingest \
  -H "Authorization: ApiKey $SEQ_API_KEY" \
  -H 'content-type: application/json' \
  -d '{ … }'
```

The event gets a sequence number in its stream, and its leaf enters the next batch.

## 3. Read the head

```bash theme={null}
curl -H "Authorization: ApiKey $SEQ_API_KEY" \
  "http://localhost:8080/api/v1/head?tenant_id=$TENANT&store_id=$STORE"
```

`head` is the current sequence position for that tenant and store — how you know whether your event
landed.

## 4. Get the commitment and an inclusion proof

```bash theme={null}
curl -H "Authorization: ApiKey $SEQ_API_KEY" \
  http://localhost:8080/api/v1/commitments/$BATCH_ID
```

That returns the batch's `events_root`, state roots, and sequence range. To verify an individual
event, pair it with an inclusion proof from the gRPC v2 service (`GetInclusionProof`) and recompute
the root locally.

<Warning>
  Recompute against the root **read from the chain**, not the one this API returns. Comparing an
  API-supplied root to an API-supplied proof verifies nothing — the on-chain value is what makes it
  trust-minimised. Full walkthrough:
  [verification example](/set/stateset-set-l2-verification-example).
</Warning>

## 5. Anchor

```bash theme={null}
curl -X POST http://localhost:8080/api/v1/anchor \
  -H "Authorization: ApiKey $SEQ_API_KEY"

curl -H "Authorization: ApiKey $SEQ_API_KEY" \
  http://localhost:8080/api/v1/anchor/status
```

Anchoring submits the commitment to [Set L2](/set/stateset-set-l2). Until it lands, you have a
sequenced event; after, you have a verifiable one.

## Run the full demo

```bash theme={null}
./scripts/run_demo.sh        # or run_e2e_demo.sh
```

## Next

<CardGroup cols={2}>
  <Card title="Sequencer overview" icon="book" href="/stateset-sequencer/stateset-sequencer">
    What VES is and why it exists.
  </Card>

  <Card title="Architecture deep dive" icon="sitemap" href="/stateset-sequencer-architecture">
    Every component in detail.
  </Card>

  <Card title="Operations" icon="gauge" href="/stateset-sequencer/stateset-sequencer-operations">
    Running it in production.
  </Card>

  <Card title="Verification" icon="shield-check" href="/set/stateset-set-l2-verification">
    Prove inclusion yourself.
  </Card>
</CardGroup>
