solana_kit_loader

pub package website CI codecov

Dart helpers for Solana's BPF Loader v3 (Upgradeable) and Loader v4 programs.

Usage

import 'dart:typed_data';

import 'package:solana_kit_addresses/solana_kit_addresses.dart';
import 'package:solana_kit_loader/solana_kit_loader.dart';

final instruction = getWriteInstruction(
  programAddress: solanaLoaderV3ProgramProgramAddress,
  bufferAccount: const Address('11111111111111111111111111111111'),
  bufferAuthority: const Address('11111111111111111111111111111112'),
  offset: 0,
  bytes: Uint8List.fromList([1, 2, 3]),
);

Key APIs

  • Program constants: solanaLoaderV3ProgramProgramAddress, bpfLoaderUpgradeableProgramAddress, and loaderV4ProgramAddress.
  • Generated Loader v3 instructions: initialize buffer, write, deploy with max data length, upgrade, set authority, close, extend program, and checked authority update.
  • Handwritten Loader v3 account-header codecs: BufferAccount and ProgramDataAccount.
  • Loader v4 instructions: write, truncate, deploy, retract, transfer authority, and finalize.
  • Handwritten Loader v4 account-header codec: ProgramStateAccount.
  • Planning helpers: getDeployProgramInstructionPlan and getUpgradeProgramInstructionPlan chunk program bytes into loader writes before the deploy or upgrade instruction.

Uploading programs

Prepare the buffer and program accounts before running the planning helpers. Their sequential plans allow buffer writes to span transactions. The final deploy or upgrade executes after all writes succeed, so normal program binaries work with the standard transaction planner and executor. If a write fails, the existing program remains unchanged and the prepared buffer can be reused or closed.

Libraries

solana_kit_loader
BPF Loader v3 (Upgradeable) and Loader v4 support for Solana Kit.