Borsh (Binary Object Representation Serializer for Hashing) is the default serialization format for Anchor account and instruction data on Agave 4.1.1. bytemuck enables zero-copy casting of plain-old-data account layouts when you control alignment and validation. Pick Borsh for flexibility; pick bytemuck for CU-sensitive hot paths.
// Anchor account with discriminator// space = 8 + UserMeta::serialized_size() // or INIT_SPACE in newer Anchor// Never bytemuck-cast untrusted accounts without owner + length checks
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026