soltrace 0.1.0

Structured, Borsh-serialized Anchor events as a drop-in replacement for msg! in Solana programs.
Documentation
  • Coverage
  • 100%
    21 out of 21 items documented0 out of 10 items with examples
  • Size
  • Source code size: 64.29 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.61 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 12s Average build duration of successful builds.
  • all releases: 1m 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • GarvitDadheech/SolTrace
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • GarvitDadheech

SolTrace — structured, Borsh-serialized Anchor events for Solana programs.

Why this exists

Solana programs rely on msg! for observability, but msg! performs string formatting on-chain. For a swap instruction logging an amount and a pubkey, msg! costs roughly 11,000 CU. SolTrace replaces that with a single emit! call over a Borsh-serialized struct, cutting the same log entry to ~781 CU — a 92.96% reduction.

The emitted events are standard Anchor events, visible as Program data: entries in transaction metadata and decodable by any Borsh-aware client.

Quick start

use anchor_lang::prelude::*;
use soltrace::{sol_info, sol_warn};

#[derive(AnchorSerialize, AnchorDeserialize)]
pub struct SwapExecuted {
    pub amount: u64,
    pub user: Pubkey,
}

pub fn swap(ctx: Context<Swap>, amount: u64) -> Result<()> {
    sol_info!("swap_executed", SwapExecuted {
        amount,
        user: ctx.accounts.user.key(),
    });
    Ok(())
}

Feature flags

Flag Default Effect
devnet-only off Compiles out all emit! calls. Enable in mainnet builds.
no-entrypoint off Passes through to anchor-lang/no-entrypoint.