Expand description
§jiminy-layouts
Standard zero-copy account layouts for well-known Solana programs.
This crate provides #[repr(C)] structs with Pod and FixedLayout
implementations for SPL Token accounts, Mint accounts, and other
widely-used on-chain data structures. These layouts are compatible
with jiminy-core’s pod_from_bytes() for direct zero-copy access.
§Why a separate crate?
jiminy-solana provides function-based field readers (e.g.,
token_account_owner(account)). This crate provides struct-based
overlays that map the entire account into a typed struct - useful when
you need to read multiple fields efficiently.
§Layouts
| Struct | Program | Size |
|---|---|---|
SplTokenAccount | SPL Token | 165 bytes |
SplMint | SPL Token | 82 bytes |
SplMultisig | SPL Token | 355 bytes |
NonceAccount | System program | 80 bytes |
StakeState | Stake program | 200 bytes |
§Coverage philosophy
This crate targets account types that programs commonly read cross-program. SPL Token accounts dominate that set. Nonce and Stake accounts are included because staking programs and durable-transaction workflows frequently inspect them. Additional layouts (e.g., Metaplex Token Metadata) can be added as the ecosystem matures.
§Example
use jiminy_layouts::SplTokenAccount;
use jiminy_core::account::{pod_from_bytes, FixedLayout};
let data: &[u8] = &account.data;
let token = pod_from_bytes::<SplTokenAccount>(data)?;
let owner = token.owner;
let amount = u64::from_le_bytes(token.amount);§Important
These are external (non-Jiminy) account layouts - they do NOT have the Jiminy 16-byte header. They are meant for reading accounts owned by other programs (SPL Token, System, Stake, etc.).
Structs§
- Nonce
Account - Zero-copy overlay for a system program durable nonce account (80 bytes).
- SplMint
- Zero-copy overlay for an SPL Token mint account (82 bytes).
- SplMultisig
- Zero-copy overlay for an SPL Token multisig account (355 bytes).
- SplToken
Account - Zero-copy overlay for an SPL Token account (165 bytes).
- Stake
State - Zero-copy overlay for the fixed prefix of a stake account (200 bytes).