solana_kit_loader 0.5.0
solana_kit_loader: ^0.5.0 copied to clipboard
BPF Loader v3 (Upgradeable) and Loader v4 instructions, accounts, and helpers for Solana Kit.
solana_kit_loader #
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, andloaderV4ProgramAddress. - 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:
BufferAccountandProgramDataAccount. - Loader v4 instructions: write, truncate, deploy, retract, transfer authority, and finalize.
- Handwritten Loader v4 account-header codec:
ProgramStateAccount. - Planning helpers:
getDeployProgramInstructionPlanandgetUpgradeProgramInstructionPlanchunk 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.