API Reference

Complete API documentation for litesvm-go. Method names mirror the Rust LiteSVM builder where possible; getter / setter pairs use the same Go convention (Clock / SetClock, Rent / SetRent, ...).

API Sections

Quick Reference

Handle Setup

import (
litesvm "github.com/LiteSVM/litesvm-go"
solana "github.com/gagliardetto/solana-go"
)
svm, err := litesvm.New()
if err != nil {
// handle error
}
defer svm.Close()

Account Management

MethodDescription
Airdrop(pubkey, lamports) errorFund an account
Balance(pubkey) (uint64, bool, error)SOL balance; bool reports whether the account exists
GetAccount(pubkey) *AccountRetrieve an account handle (nil if missing)
SetAccount(pubkey, *Account) errorStore account state directly
MinimumBalanceForRentExemption(dataLen int) (uint64, error)Compute rent-exempt minimum
NewAccount(lamports, data, owner, executable, rentEpoch) (*Account, error)Build an Account handle for SetAccount

Program Management

MethodDescription
AddProgram(programID, bytes) errorLoad program from bytes
AddProgramFromFile(programID, path) errorLoad program from .so file
AddProgramWithLoader(programID, bytes, loaderID) errorLoad under a specific loader (advanced)

Transactions

MethodDescription
SendLegacyTransaction(txBytes) (*TxOutcome, error)Execute a legacy transaction
SendVersionedTransaction(txBytes) (*TxOutcome, error)Execute a v0+ transaction
SimulateLegacyTransaction(txBytes) (*TxOutcome, error)Simulate without state changes
SimulateVersionedTransaction(txBytes) (*TxOutcome, error)Simulate v0+ without state changes
LatestBlockhash() (solana.Hash, error)Current blockhash
ExpireBlockhash() errorAdvance to a new blockhash
GetTransaction(signature) *TxOutcomeLook up transaction in history (nil if absent)
litesvm.BuildTransferTx(payerSeed, to, lamports, blockhash) ([]byte, error)Test helper that builds a signed legacy transfer without pulling in solana-go

Configuration

MethodDescription
SetSigverify(bool) errorEnable / disable signature verification
Sigverify() (bool, error)Read the current setting
SetBlockhashCheck(bool) errorEnable / disable blockhash validation
SetTransactionHistory(int) errorCapacity of in-memory tx history (0 disables)
SetLogBytesLimit(int) errorPer-tx log byte cap (negative = unlimited)
SetLamports(uint64) errorDefault lamports for new airdrop-pool accounts
SetSysvars() errorReset sysvars to defaults
SetBuiltins() errorReload built-in programs
SetDefaultPrograms() errorReload SPL Token, Memo, etc.
SetPrecompiles() errorEnable ed25519 / secp256k1 precompiles
WithNativeMints() errorSeed wrapped-SOL mint
SetFeatureSet(*FeatureSet) errorInstall a feature gate set
SetComputeBudget(ComputeBudget) errorApply a compute budget
ComputeBudget() (ComputeBudget, bool, error)Read the current budget (bool reports "explicitly set")

Time and Sysvars

MethodDescription
WarpToSlot(slot uint64) errorJump to a specific slot
Clock() (Clock, error)Read the Clock sysvar
SetClock(Clock) errorOverwrite the Clock sysvar
Rent() (Rent, error)Read the Rent sysvar
SetRent(Rent) errorOverwrite the Rent sysvar
EpochSchedule() (EpochSchedule, error)Read the EpochSchedule sysvar
SetEpochSchedule(EpochSchedule) errorOverwrite the EpochSchedule sysvar
EpochRewards() (EpochRewards, error)Read the EpochRewards sysvar
SetEpochRewards(EpochRewards) errorOverwrite the EpochRewards sysvar
LastRestartSlot() (uint64, error)Read last-restart-slot
SetLastRestartSlot(uint64) errorSet last-restart-slot
SlotHashes() ([]SlotHash, error)Read the SlotHashes sysvar
SetSlotHashes([]SlotHash) errorOverwrite the SlotHashes sysvar
SlotHistory() (*SlotHistory, error)Read the SlotHistory sysvar (handle)
SetSlotHistory(*SlotHistory) errorOverwrite the SlotHistory sysvar
StakeHistory() ([]StakeHistoryItem, error)Read the StakeHistory sysvar
SetStakeHistory([]StakeHistoryItem) errorOverwrite the StakeHistory sysvar

Utilities

MethodDescription
litesvm.Version() stringVersion string reported by the underlying Rust litesvm crate

Is this page helpful?

目次

ページを編集
© 2026 Solana Foundation. 無断転載を禁じます。
API Reference | Solana