evt-store.hub

Documentation

Usage manual

Everything you need to go from an Anchor instruction to a typed event your app can read over HTTP. Follow the steps in order; each one states exactly what you should have at the end.

Concepts

ProgramYour Solana smart contract (Anchor). It emits events.
evt-store-srvA small shared program your program calls by CPI.
event_idA stable string you choose, e.g. "transfer_v1". Routing key.
IDLAnchor JSON describing instructions and event structs.
EventOne decoded payload, stored with its signature and slot.
API keyBearer token your backend uses to call this hub.
Emission fee2,000 lamports per CPI, paid by the signer. Free to read.

Flow: your instruction calls event_store!, which calls evt-store-srv::emit; the runtime writes the payload into the transaction logs; one indexer forwards it to this hub; the hub decodes it with your IDL and stores it.

1. Install the macro

Requirements: Anchor CLI 1.2.2 or newer (older CLIs do not write the events section into the IDL).

[dependencies]
anchor-lang = "0.32.1"
evt-store = "0.1"
evt-store-srv = { version = "0.1.0", features = ["cpi"] }
base64 = "0.22"

Declare your payloads as #[event] structs. That is what puts them in the IDL, and therefore what lets the hub decode them.

use anchor_lang::prelude::*;

#[event]
pub struct Transfer {
    pub from: Pubkey,
    pub to: Pubkey,
    pub amount: u64,
}

2. Emit an event

Call the macro with three arguments: the CPI context, the event ID as a string literal, and a struct literal.

use evt_store::event_store;

pub fn handler(ctx: Context<Play>, from: Pubkey, to: Pubkey, amount: u64) -> Result<()> {
    // … your game logic …

    event_store!(
        ctx.accounts.evt_store_ctx(),
        "transfer_v1",              // routing key — you choose it
        Transfer { from, to, amount } // struct from your IDL
    )?;
    Ok(())
}
Why an explicit ID? The hub routes on (program, event_id). Renaming a struct does not change the ID, and two programs can use the same struct name without colliding. Pick a name you will keep:transfer_v1, pool_settled_v2, …

Your accounts struct needs an evt_store_program account (the evt-store-srv program) and the program account itself as caller_program. See the example programs page for a complete snippet.

Emission fee

Each emission costs 2,000 lamports, paid by a payer account of the CPI context. You choose who signs: a player, or a server key of your app. The fee is taken before the log is written — a failed emission costs nothing.

let [fees_pda, _bump] =
    Pubkey::find_program_address(&[b"fees"], &evt_store_srv::ID);

let cpi_ctx = CpiContext::new(
    ctx.accounts.evt_store_program.to_account_info(),
    evt_store_srv::cpi::accounts::Emit {
        caller_program: ctx.accounts.my_program.to_account_info(),
        payer: ctx.accounts.payer.to_account_info(), // signer
        fees_pda: /* account at fees_pda */,
        system_program: ctx.accounts.system_program.to_account_info(),
    },
);

Add payer and fees_pda to your accounts struct. They are the only two accounts the fee adds to your transaction.

3. Create your account

  1. 1. Open the landing page and click your wallet (Phantom, Solflare, Backpack).
  2. 2. Approve the signature request. It is a message, not a transaction.
  3. 3. You land on Profile. Your public key is now your account.
  4. 4. Under API keys, create one and copy it. It is shown once.
Keep the key server-side. It authenticates as Authorization: Bearer esk_…. Revoking it in the profile disables it immediately; your programs and events are kept.

4. Register the program

Go to Programs → Register.

Display name
Free text, for your dashboard only.
Program ID
The base58 address of your deployed smart contract — the value in declare_id!(). Not the IDL path, not the transaction id.
Anchor IDL
The JSON in target/idl/<program>.json after anchor build. Must contain events and types.

The hub checks that the IDL address equals the Program ID you entered. A mismatch is rejected.

5. Declare event IDs

On the program page, fill Declare an event ID: the ID you wrote in the macro, and the IDL struct that describes it. Repeat for each ID your program emits.

event_store!(ctx, "transfer_v1", Transfer { … })
                       └──────┬──────┘   └────┬────┘
                          event_id       IDL struct

To change the shape of a payload later, open the ID already declared and click New version. Old events keep the version they were received with.

Maintainer: initialise the fee account

Done once per deployment by the operator, not by each developer. The emission fee is collected on a shared account that must exist before the first emission — there is no automatic creation.

evt-store-srv::init_fees {
  upgrade_authority: <program upgrade authority, signer>,
  program_data:      <ProgramData account>,
  fees_pda:          <PDA of seeds ["fees"]>,
  system_program,
}

It deposits the rent (≈0.00095 SOL) and cannot be replayed. emit fails with a clear account error until it has been run.

6. Point the indexer at evt-store-srv

This part is configured once by the operator of the platform, not by each developer. The indexer (Helius, raw transaction webhook) watches the evt-store-srv program and forwards each transaction to:

POST https://<hub-host>/ingest/helius/<HELIUS_INGEST_SECRET>
Content-Type: application/json

[ { "signature": "…", "slot": 123, "meta": { "err": null, "logMessages": [ … ] } } ]

The hub answers 200 immediately and processes in the background. Duplicate deliveries are ignored. If you self-host, the secret lives in HELIUS_INGEST_SECRET.

7. Read events

In the dashboard, Events lists what was decoded. From your backend:

curl "https://<hub-host>/events?programId=<program>&eventId=transfer_v1&limit=50" \
  -H "Authorization: Bearer esk_…"

Response:

{
  "items": [
    {
      "id": "…",
      "eventId": "transfer_v1",
      "programAccountId": "…",
      "schemaVersion": 1,
      "signature": "…",
      "logIndex": 3,
      "slot": 268431000,
      "status": "confirmed",
      "payload": { "from": "…", "to": "…", "amount": "1000000" },
      "createdAt": "2026-11-22T00:00:00.000Z"
    }
  ],
  "nextCursor": null
}

Filters: programId, eventId, signature, fromSlot, toSlot, cursor, limit (max 200). Pass nextCursor back as cursor to page. Large integers are returned as strings to avoid losing precision.

Schema versions

An event ID has exactly one schema per version. Saving a new version:

  • • never rewrites events already stored;
  • • marks the previous version superseded (still visible);
  • • applies to events received after the change.

Saving the identical schema again is rejected, so version numbers cannot drift.

Pricing and rate limits

Emission2,000 lamports per event. Paid by the signer, on chain. The fee account is initialised once by the operator.
ReadingFree. /events and /programs, with an API key.
Rate limit3 requests per second per API key (small burst allowed).
Retention12 months, then automatic deletion.

Above the rate limit, the API answers 429 with Retry-After and X-RateLimit-* headers. A refused request costs nothing and touches no data.

Troubleshooting

The IDL is rejected: “no events section”

Your Anchor CLI is too old. Rebuild with 1.2.2+ and paste target/idl/<program>.json again.

The Program ID does not match the IDL

The address in the IDL and the value you typed differ. Copy the programId from the IDL or from declare_id!().

Events stay empty after an emission

Usually one of: the event ID was never declared; the indexer does not watch evt-store-srv; the transaction failed (failed transactions emit nothing).

A payload is stored but payload is null

The schema was not available or the struct uses nested types the decoder does not support yet. The raw bytes are kept.

429 Too Many Requests

More than 3 calls per second on this API key. Wait for Retry-After seconds and space your polling.

emit fails with “account not found” on fees_pda

The operator has not run init_fees yet. It must be called once after deployment.

InvalidEmissionFee or insufficient lamports

The payer account of your CPI context cannot cover the 2,000 lamports fee. Fund it or choose another signer.

401 from /programs or /events

The API key is wrong or revoked. Create a new one in Profile.

Signature refused by the wallet

The site origin changed (port or host). AUTH_DOMAIN must match the exact page host, port included.

Current limits

  • • Events are confirmed; a finalized status will come later.
  • • Read-only HTTP: push delivery (WebSocket, long polling) is not available yet.
  • • No automatic replay if the indexer skips deliveries.
  • • Events are deleted 12 months after reception (see Pricing).
  • • Nested structs and enums are not decoded yet (payload kept as raw bytes).