A pure Zig port of the Solana SDK core types and common SPL program interfaces. It mirrors the Rust solana-sdk APIs (no syscalls) so the same types can be used by on-chain programs and off-chain clients.
- Core types:
PublicKey/PDA helpers,Hash,Signature,Keypair - Instructions & errors:
Instruction,AccountMeta,ProgramError,InstructionError,TransactionError - Serialization: bincode, borsh, short vector encoding, C-compatible
COption - SOL helpers: lamport/SOL conversions, durable nonce types, sysvar IDs
- SPL programs: Token, Memo, and Stake program types and instruction builders
- Pure Zig: no Solana runtime syscalls; works anywhere Zig runs
- Zig 0.15.2 or newer (matches
build.zig.zon). CI pins the solana-zig bootstrap releasev1.52.0(bundled Zig 0.15.2); you can fetch the same toolchain locally via./install-solana-zig.sh.
- Add the package to your project (for example with
zig fetch --save <git-url>or a local.pathentry inbuild.zig.zon). - Wire the module in
build.zig:
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const sdk_dep = b.dependency("solana_sdk", .{ .target = target, .optimize = optimize });
const sdk = sdk_dep.module("solana_sdk");
const exe = b.addExecutable(.{ /* ... */ });
exe.root_module.addImport("solana_sdk", sdk);const std = @import("std");
const sdk = @import("solana_sdk");
pub fn main() !void {
var kp = sdk.Keypair.generate();
const message = "hello, solana";
const sig = try kp.sign(message);
try sig.verify(message, kp.pubkey().asBytes());
var pk_buf: [sdk.PublicKey.max_base58_len]u8 = undefined;
var sig_buf: [sdk.signature.MAX_BASE58_LEN]u8 = undefined;
const pk_b58 = kp.pubkey().toBase58(&pk_buf);
const sig_b58 = sig.toBase58(&sig_buf);
std.debug.print("pubkey: {s}\nsignature: {s}\n", .{ pk_b58, sig_b58 });
}zig build testsrc/root.zig– main entry point re-exporting all modulessrc/public_key.zig,src/signature.zig,src/keypair.zig– core crypto typessrc/instruction.zig– instruction and account metadatasrc/error.zig,src/instruction_error.zig,src/transaction_error.zig– error typessrc/bincode.zig,src/borsh.zig,src/short_vec.zig,src/c_option.zig– serialization helperssrc/native_token.zig,src/nonce.zig,src/sysvar_id.zig– SOL utilities and sysvarssrc/spl/– SPL Token, Memo, and Stake program types and instruction builders
Early-stage SDK surface for Solana in Zig. Interfaces follow the upstream Rust SDK where practical; expect additions and minor breaking changes while the API settles.