evt-store

Crates.ioevt-store
lib.rsevt-store
version0.1.0-alpha.2
created_at2025-12-29 11:30:12.341002+00
updated_at2026-01-02 15:07:11.206685+00
descriptionProc-macro to emit events to evt-store-srv from Anchor programs via CPI
homepage
repositoryhttps://github.com/solTrust/evt-store
max_upload_size
id2010467
size42,145
renaud Devers (chavers)

documentation

README

evt-store-macro

Procedural macro to emit events to an external evt-store service from Anchor (Solana) programs via CPI. It serializes your event struct with AnchorSerialize, base64‑encodes the bytes, and calls evt_store_srv::cpi::emit(ctx, data_b64, event_type) for you.

Status

Experimental. API may change.

Installation

Add to your Anchor program's Cargo.toml:

[dependencies]
evt-store= { version = "0.1"}
anchor-lang = "0.30" # or your version
base64 = { version = "0.22", default-features = false, features = ["alloc"] }

Notes:

  • The macro expansion references anchor_lang, base64, and evt_store_srv at your call site. Ensure they are available in your program.
  • MSRV: Rust 1.70+ (Edition 2021).

Usage

use anchor_lang::prelude::*;
use evt_store_macro::event_store;

#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct Transfer {
    pub from: Pubkey,
    pub to: Pubkey,
    pub amount: u64,
}

pub fn handler(ctx: Context<SomeCtx>, from: Pubkey, to: Pubkey, amount: u64) -> Result<()> {
    
    // Build your event as a struct literal so the macro can infer its type name
    event_store!(ctx.accounts.evt_store_ctx(), Transfer { from, to, amount })?;
    Ok(())
}

What the macro does under the hood:

  • AnchorSerialize::try_to_vec(&event) to bytes
  • base64‑encodes the bytes
  • computes the event type name from the struct identifier (e.g., "Transfer")
  • performs ::evt_store_srv::cpi::emit(ctx, data_b64, event_type)

Macro contract

  • Call as event_store!(CTX, EventStruct { ... }) — the second argument must be a struct literal so the type name can be inferred.
  • Ensure your struct implements AnchorSerialize.
  • Your program must have access to the CPI interface evt_store_srv::cpi::emit.

License

AGPL-3.0-only. See LICENSE.

Security

This crate is intended for on-chain programs. Carefully validate any data you log and ensure emitted events do not leak sensitive information.

Contributing

Issues and PRs welcome. By contributing you agree that your contributions are licensed under the AGPL-3.0-only license of this repository.

Commit count: 0

cargo fmt