Why SQL over Arkiv
arkiv_query filters and pages. It returns at most 200 results per page, newest first, with no JOIN, no GROUP BY, no ORDER BY on attributes and no aggregation beyond a count. That answers “give me this entity”. It does not answer “which wallets create the most entities?”
With arkiv_query
- Page through every live entity, 200 per call, on a shared rate limited budget.
- Collect the creator of each one in your own code.
- Count, sort and keep the top ten yourself.
With SQL here
SELECT creator, count(*) AS n
FROM entities
GROUP BY creator
ORDER BY n DESC
LIMIT 10Runs in milliseconds in your tab. It is the Top 10 creators chart on a featured dashboard.
SQL also fixes a trust problem. Attributes are written by whoever creates an entity, so anyone can create one with project = arkiv-sql-indexer-dash. $creator is set by the chain. The app reads its own entities by creator (the app wallet), so look alike entities never count as its own.
Who this protects
The project enters two tracks, Open Source and Security. For each one: who is stuck or misled today, and what changes for them from the first day.
Open Source
- Who
- Arkiv app teams, analysts and AI agents who need GROUP BY or JOIN over Arkiv data.
- Today
- They page
arkiv_query200 rows at a time on a metered anonymous budget (on 18 October its header reported 10,000 cost units an hour, and one broad query used it up) and count in their own code, or they write their own indexer frometh_getLogs. - What changes
- From day one: a documented data contract (manifest, delta, two Parquet files with fixed columns), an MIT indexer that runs without an API key, and hosted files that DuckDB or Python read without asking anyone. This app reads only that contract. On 20 October an analyst with only the DuckDB CLI 1.5.5 ran
examples/top-creators.shagainst the hosted index and had the ten top creators in 3.0 seconds, with no API key and no RPC call.
Security
- Who
- A viewer of a Featured dashboard, and a widget author.
- Today
- Anyone can create a dashboard with
project = arkiv-sql-indexer-dash,userset to the app wallet,login = arkivand the slug of a Featured dashboard. An app that trusted attributes would show it as Featured and run its SQL in your tab. A transferred, editable widget could have its author rewritten. - What changes
- Every read filters on the chain set
$creator, and Featured also needs$ownerto be the app wallet. Decoders recheck the creator, an address is shown next to every Featured chip (theuserattribute on dashboards, the chain's$owneron widget cards and widget pages; for Featured both are always the app wallet), and user widgets are readonly so no new owner can rewrite the author.
Check the Security claim yourself: the query project = str('arkiv-sql-indexer-dash') AND NOT ($creator = addr(0x1f61c3cac1612c020f64739b128c5f198939c8cd)) returned no entities on 20 October 2026. Anything it ever returns is ignored by this app.
Why Arkiv
Arkiv moves the trust point from a database operator to the public chain. With an ordinary database you trust whoever runs it to say which rows exist, who wrote them and when they expire. Here those facts are chain state: the chain sets $creator and $owner, enforces the expiry block, and logs every create, patch, extend, transfer and delete publicly.
- CompletenessAnyone can replay the public logs from block zero without an API key, or run the MIT indexer, and compare the result with the hosted files.
- FreshnessVerify rereads rows from an RPC node. Anyone can choose the RPC endpoint, self host this app, or run their own node.
- Still trustedVerify trusts the RPC node it asks, since
eth_getProofis not available. Choosing your own node moves that trust to a party you pick; it does not remove it.
| Instead of Arkiv | What breaks |
|---|---|
| Postgres run by an operator | The operator decides which rows exist. It can keep a row after its expiry, write rows under any author and drop rows, and readers cannot check. Here the chain sets $creator and the expiry block, and Verify rereads any row from an RPC node. |
| IPFS | Blobs by content hash: no typed attributes to filter on, no expiry, no owner who can transfer or delete, no query. Widget lifetimes, extension by anyone and transfer to the author would all disappear. |
| A subgraph | No expiry semantics: a row lives until a mapping removes it, so widget lifetimes would be app code nobody can check. Every schema change means a new mapping and a redeploy. Readers trust whoever hosts it. This indexer works for any entity and any attributes with no redeploy, expiry comes from the chain, and Verify rechecks any row against an RPC node. |
| Our own API | A server we run that answers queries. Readers could not recompute its answers, so they would trust us to report rows faithfully. This project publishes plain files instead, which anyone can rebuild from public logs and compare. |
What stays off Arkiv on purpose
| Kept off chain | Why |
|---|---|
| Parquet snapshots, delta and manifest | Derived data that anyone can rebuild by replaying public logs. A cache, not a record. |
| DuckDB | Computation, not data. SQL runs in your tab and never on a server. |
| Session cookies, login nonces, rate limits | Short lived state of one web server. On chain they would be public and outlive their purpose. |
| Payload copies | Payloads stay on chain and load on demand. The indexer never copies them into Parquet. |
| The API key | A secret, kept in the server runtime only. A test checks that no build or browser file names it. |
| Email, handles, Privy IDs | Personal data. Only the wallet address and the login provider name are written. |
Architecture
The indexer turns the chain into files. The browser turns the files into a database and keeps it current.
- Arkiv RPCPublic logs and keyed lookups.
- Bun indexerWrites Parquet and a delta.
- Next.js proxyServes them at
/data. - DuckDB WASMRuns your SQL in the tab.
- Indexer
- Scans latest state in key order with pages of at most 100 entities. Attributes are filled newest first with
$keylookups of at most 50 keys. Rabdi retains roughly 1,000 blocks of logs; the indexer rebuilds when it falls behind that window. Live sync applies creates, patches, extensions, transfers and deletes every 5 blocks. - Snapshot, delta, live tail
- A new versioned pair of Parquet files every 30 blocks, keeping the latest two. A JSON delta carries every key changed since that snapshot, and the browser polls it every 2 seconds. Between deltas, the browser tails chain logs every 4 seconds and fetches attributes for new keys at most every 20 seconds.
- DuckDB WASM
- Merges the three sources into two views,
entitiesandattributes. Every query runs in your tab; there is no server SQL endpoint. /dataproxy- Next.js forwards manifest, delta and Parquet requests to
INDEXER_URL(the hosted indexer for this app, or your own), with ETags and Range support. If the indexer is down, it serves the same files from a read only mount. - Polling, not events
- The indexer and the browser poll
eth_getLogsdirectly instead of using the SDK event watcher. That gives explicit block windows and checkpoints: the indexer commits one per batch, and the browser tail starts atdelta.toBlock + 1, exactly where the indexer's published window ends. /api/rpcproxy- Browser reads (live head, logs, payloads, verify) go through this same origin proxy. It allows read only methods, limits each client to 10 requests a second, and adds the server's API key when one is configured. No key ever reaches the browser.
Run your own indexer
The indexer is the reusable part. Point it at all of Arkiv, or at a subset with INDEX_EXPRESSION (for example $creator = addr(…)), and it publishes a manifest, snapshots and a delta that any app, script or agent can read.
git clone https://github.com/SlayerAnsh/hackathon-duckdb-indexer.git sql-indexer
cd sql-indexer
cp .env.example .env
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d --build- No API keyBackfill and live sync read public logs. The key is used only when you opt in.
- Plain filesRead
manifest.json, then the Parquet files it lists, with DuckDB or any Parquet tool. - Docker or BunDocker Compose for the full stack, or Bun 1.3 to run the indexer and the app directly.
The hosted indexer behind this app serves the same files at arkiv-sql-indexer.dokploy.anshudhar.dev, so you can query all of Rabdi with DuckDB without running anything.
README.md, docker-compose.yml, .env.example, apps/indexer/test/keyless.test.tsEntity model
The app writes three entity types, each with the attribute project = arkiv-sql-indexer-dash. Attributes are typed and queryable. The JSON payload holds the details, stays on chain, and never enters Parquet; the Payload button loads it on demand.
widget
- Attributes
- type, project, user (addr), login, name, chart
- Payload
- SQL, chart mapping, number format, chosen lifetime
- Lifetime
- 1, 7, 30 or 90 days
dashboard
- Attributes
- type, project, user (addr), login, title
- Payload
- Title and description
- Lifetime
- 90 days, renewed on each organize save
link
- Attributes
- type, project, user (addr), dashboard (key), widget (key)
- Payload
- Size, position and a copy of the widget name
- Lifetime
- Follows its dashboard
A dashboard holds at most 48 links and never the same widget twice. The login attribute records only the provider name; no email, handle or Privy user ID is written.
Who owns what
You log in with Privy (Google, Discord, X or Telegram) and get an embedded wallet. The app wallet creates every entity, so $creator stays one known address. A widget is then handed to you.
- SaveThe app wallet creates the widget. Saving is free.
- Transferred to youIn the same transaction it moves to your wallet.
- Extend, transfer or deleteSigned in your browser and paid in tGLM. Anyone logged in may extend it.
- ExpiresAfter its lifetime ends, unless someone extends it.
| Action | Who can do it | How |
|---|---|---|
| Save a widget | Any logged in user | Through the app, free. |
| Edit a widget | Its Arkiv owner | Through the app, free. Saves a new version and repoints your dashboard links. |
| Extend a widget | Any logged in user | Signed in the browser, paid in tGLM. Adds its lifetime again, up to 90 days ahead. |
| Delete or transfer a widget | Its Arkiv owner | Signed in the browser, paid in tGLM. |
| Edit a dashboard | Its owner (the user attribute) | Through the app. Dashboards and links stay owned by the app wallet. |
- Why readonly
- Once a widget is yours the app no longer controls it, so its attributes and payload are frozen for life. A new owner cannot rewrite the author, or set it to the app wallet and hand it back to fake a Featured widget. That is also why editing saves a new version.
- Why anyone can extend
- A widget on someone else's dashboard may matter to you. Permissionless extension lets you keep it alive, paying your own fee, without being able to change it.
- Why one transaction
- Saving creates the widget and transfers it to you in one batch, with its key predicted in advance. Either both happen or neither, so a widget is never left with the app wallet, and a new placement never points at a widget that failed to save. Organize saves a whole layout the same way.
Featured dashboards and widgets belong to the app wallet itself: it is both their user and their Arkiv owner. The server extends them on a schedule, so they stay live.
Expiry and lifetimes
Every Arkiv entity has an expiry block. The index honours it instead of keeping data forever, in three places:
- Snapshot buildCopies only rows with
expires_atabove the head. - Indexer sweepDeletes expired rows every batch and keeps only two snapshot versions.
- Browser viewsHide rows whose expiry is at or below
live_head, read from the RPC.
So a row leaves SQL the moment its block passes, with no event needed. Extending a widget adds its chosen lifetime again, capped at 90 days remaining.
| Entity | Lifetime | Why |
|---|---|---|
| Widget | 1, 7, 30 or 90 days, your choice | You decide how long a public query stays public. Each extend adds that lifetime again, so it lives while someone keeps renewing it. The 90 day cap is an app rule, not an Arkiv limit. |
| Dashboard | 90 days, renewed on every save | Editing a dashboard is the activity that keeps it alive. |
| Link | Same expiry as its dashboard | A placement never outlives its dashboard or dies before it. |
| Featured | 90 days, kept alive by the app | A lease: every 6 hours the app wallet checks Featured entities and extends any with fewer than 30 days left back to 90. The first renewal falls due about 60 days after creation. |
When a widget expires or is deleted, its dashboard slot keeps the copied name and runs no SQL.
An older snapshot file can hold a row until it is pruned, and someone who copied data while it was live keeps their copy. Expiry here is not a promise to erase third party copies.
apps/indexer/src/snapshot.ts, apps/indexer/src/store.ts, packages/core/src/views.tsVerify a row
When a result has a key column, Verify (or Verify page for every row) asks the RPC for each key's current update block, expiry and owner, in batches of 50, and compares them with your copy:
- ok
- The chain has the same last update and expiry as your copy.
- extended
- The chain holds a newer update with a later expiry.
- stale
- The chain holds a different version than your copy.
- expired
- The expiry block on chain is at or below the live head.
- deleted
- The RPC no longer returns the entity. This cannot tell deletion from expiry.
This is a consistency check against the RPC, not a cryptographic proof, because eth_getProof is not available on Arkiv.
The chain is the reference, not the index. To see a stale copy caught, start an indexer with SYNC_PAUSED=true on an old data directory and run examples/verify_against_chain.py against it: it applies the same rule to the 50 newest rows. Recorded on 20 October 2026 at 01:58 UTC: a copy paused at block 757,400, 48,478 blocks behind, came back 45 deleted and 5 extended; the live hosted index, at snapshot block 805,871 with the chain head at 805,881, came back 50 ok. That second result drifts with live churn: about 2,800 keys change per hour, so a rerun can show a few stale or extended rows updated since the last snapshot. In this app the browser live tail replays chain logs on top of a paused index, so here a stale copy shows only until the tail catches up.
Reproduce it
- Open a featured dashboard. Every chart is one SQL query run by DuckDB in your tab, with its SQL one click away.
- Open the playground and run “Most placed widgets”. It joins widget and link entities and counts placements, including widgets with none.
- Run
SELECT key, creator, owner, updated_at, expires_at FROM entities LIMIT 20and press Verify page. Each row is checked against the chain. - Watch a row expire. Sort by
expires_at, wait for the chain block in the status bar to pass one, and run again. The row is gone. - Look up the app wallet. It is the creator of every app entity; see On chain evidence.
On chain evidence
Every value below was read back from Tiramisu on 20 October 2026. Each creation transaction was sent by the app wallet and stays on the explorer after the entity expires.
- App wallet, creator of every widget, dashboard and link
- 0x1f61c3cac1612c020f64739b128c5f198939c8cd
- Featured dashboard: network overview
- 0x78d7f64354c4457ae7d8193375768b11bcf91e7f64992cb02e18df4979e24376created in 0x8e538593d2516a7662fa1876ea313c5ef186a1bac877f503e7788ccb0dea20e9
- Featured dashboard: expiry watch
- 0x06d3cd9bab9569d89a08768750346cfc06b715051310dbed844162f255d0852bcreated in 0xb75afae47d011b77fc9dd5201812105bde679fe3f5e78a18a62b0a5db69814af
- Featured dashboard: creators
- 0x3f0a1beb784edd28b1373ec5edbc1b97a3b266dc15913b31020935ac52dc7256created in 0x759fb064b7b4bfef640bc58166ae68bfb19a2a1f200700c9f6e94f57425542d0
- Featured dashboard: attributes
- 0x4b0f0f42f1307982afdef3323c0444b67d2a1916038815acfcd9476b967ddc82created in 0x320d764b92cb113293f3c80187870cea5f71741f661ea77c14e3244919fd8a7b
- Featured dashboard: activity
- 0x558952f966a369a864d304d76fc0ae5fb3300b840af801e56f3ff422482cc228created in 0xa9adb7278efbcd35382824aefc90de21a564642a93a53829ded7771073fe63df
- A user owned widget, readonly and permissionlessly extendable, created and transferred in one transaction
- 0x78ca2e9ea9f292bc81a6356a89d7e73eddb6f491916209d673b6ec724b22be23created in 0xa3668515f09911d190336e92457afba8759f79f3f18870e7d5a33f7cd7a21f03
- Its owner, a Privy embedded wallet
- 0x2f4d9088ff069c17c2ae6c051e3c78911b827757
Limits and trust
- Completeness. Verify checks the rows you see. It cannot show a row the indexer left out; for that, run your own indexer and compare.
- The read proxy. Browser RPC reads go through this server's
/api/rpc. You trust it to forward them unchanged, or you self host. - Filtered indexes. With an
INDEX_EXPRESSIONthat has no$creatoror$ownerterm, keyless sync cannot see an existing entity that starts matching through a patch. - One web instance. Login nonces, rate limits and the app wallet queue live in memory.
- Everything is public. SQL, names and dashboard content are on chain. Keep personal information out of them.
Friction we measured
On Tiramisu between 18 and 20 October 2026 with SDK 0.8.1, viem 2.57.7 and Privy 3.50.0. Expected and actual behavior, versions and reproduction steps are in arkiv/friction.md.
Anonymous budget and its 429limit=10000 on 18 October, gone in one query
On 18 October the
RateLimitheader of an anonymousarkiv_queryreported 10,000 cost units, reset after about an hour, and a broad$expiresAt > u64(0)query with limit 5 used all of it. Later calls returned HTTP 429 with a plain object, not a JSON RPC error envelope. The Arkiv docs give no anonymous number, and on 20 October the header reportslimit=600, reset=60, a count of requests per minute, so the cost budget left is no longer visible. The client handles both error shapes and waits for Retry-After.Undocumented query length limit50 key terms pass, 100 fail
An OR of 50 keys (about 4,100 characters) worked; 100 keys (about 8,200) failed with
-32004 query is too long, and the failure still cost units. Lookups are chunked at 50.Flat cost per callArkiv-Cost: 100
One key, 50 keys, a full 200 row page and a failing call all showed the same cost. Batching keys is the only lever, so every lookup carries up to 50.
Monthly quota is a percentageno capacity or remaining units
Headers expose quota used as a percent, so remaining calls cannot be computed. Together with the measured change rate, this is why the indexer runs without an API key by default.
Create and transfer in one batchworked, block 803,198
The docs show
ownershipChangesonly for existing keys. A create with a salt frompredictEntityKeysplus a transfer of that key in the sameexecuteBatchworks: one transaction logs EntityCreated, then OwnershipTransferred. Prediction and send share one slot of a serial queue.Wallet transport retries4 sends instead of 1
A viem
customtransport retries 3 times by default, includingeth_sendTransaction, on codes such as -32603. With Privy signing silently that would resend a write. The wallet transport setsretryCount: 0; a probe confirmed 4 provider calls before and 1 after.Extend at the capExpiryNotExtended
An extend sets an absolute expiry and reverts when it is not later. Anyone may extend a user widget, so two viewers can race. The app computes the target from a fresh head, refuses to send at the 90 day cap, and maps the revert to the same message.
Anonymous budget, againANON_COST_LIMITED on 20 October
Browser reads went straight to the public RPC on each visitor's own budget and hit HTTP 429. They now go through the same origin
/api/rpcproxy, which adds the server's API key, and the UI shows a budget notice instead of retrying.Keyless attribute backlog809 of 36,457 pending
Without a key, attributes fill at up to 50 keys per query on the anonymous budget, newest first, while about 2,800 keys change per hour. The hosted indexer converges; rows stay queryable from log data while attributes load.