Documentazione completa delle API per litesvm-go. I nomi dei metodi rispecchiano il builder Rust
LiteSVM dove possibile; le coppie getter/setter seguono la convenzione Go
(Clock / SetClock, Rent / SetRent, ...).
Sezioni API
Gestione degli Account
Airdrop, Balance, GetAccount, SetAccount, NewAccount, programmi
Transazioni
Invio / simulazione di transazioni legacy e versionate, TxOutcome
Configurazione
Opzioni per sigverify, controllo blockhash, cronologia, limiti log, programmi predefiniti
Tempo e Sysvar
WarpToSlot, Clock, Rent, EpochSchedule, EpochRewards, SlotHashes, SlotHistory, StakeHistory
Riferimento Rapido
Configurazione dell'Handle
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()
Gestione degli Account
| Metodo | Descrizione |
|---|---|
Airdrop(pubkey, lamports) error | Finanzia un account |
Balance(pubkey) (uint64, bool, error) | Saldo in SOL; il bool indica se l'account esiste |
GetAccount(pubkey) *Account | Recupera un handle all'account (nil se assente) |
SetAccount(pubkey, *Account) error | Imposta direttamente lo stato dell'account |
MinimumBalanceForRentExemption(dataLen int) (uint64, error) | Calcola il minimo esente da rent |
NewAccount(lamports, data, owner, executable, rentEpoch) (*Account, error) | Costruisce un handle Account per SetAccount |
Gestione dei Programmi
| Metodo | Descrizione |
|---|---|
AddProgram(programID, bytes) error | Carica un programma da bytes |
AddProgramFromFile(programID, path) error | Carica un programma da file .so |
AddProgramWithLoader(programID, bytes, loaderID) error | Carica con un loader specifico (avanzato) |
Transazioni
| Metodo | Descrizione |
|---|---|
SendLegacyTransaction(txBytes) (*TxOutcome, error) | Esegue una transazione legacy |
SendVersionedTransaction(txBytes) (*TxOutcome, error) | Esegue una transazione v0+ |
SimulateLegacyTransaction(txBytes) (*TxOutcome, error) | Simula senza modificare lo stato |
SimulateVersionedTransaction(txBytes) (*TxOutcome, error) | Simula v0+ senza modificare lo stato |
LatestBlockhash() (solana.Hash, error) | Blockhash corrente |
ExpireBlockhash() error | Avanza a un nuovo blockhash |
GetTransaction(signature) *TxOutcome | Cerca una transazione nella cronologia (nil se assente) |
litesvm.BuildTransferTx(payerSeed, to, lamports, blockhash) ([]byte, error) | Helper di test che costruisce un trasferimento legacy firmato senza dipendere da solana-go |
Configurazione
| Metodo | Descrizione |
|---|---|
SetSigverify(bool) error | Abilita / disabilita la verifica delle firme |
Sigverify() (bool, error) | Legge l'impostazione corrente |
SetBlockhashCheck(bool) error | Abilita / disabilita la validazione del blockhash |
SetTransactionHistory(int) error | Capacità della cronologia tx in memoria (0 = disabilitata) |
SetLogBytesLimit(int) error | Limite in byte dei log per transazione (negativo = illimitato) |
SetLamports(uint64) error | lamport predefiniti per i nuovi account dell'airdrop pool |
SetSysvars() error | Ripristina i sysvar ai valori predefiniti |
SetBuiltins() error | Ricarica i programmi built-in |
SetDefaultPrograms() error | Ricarica SPL Token, Memo, ecc. |
SetPrecompiles() error | Abilita i precompilati ed25519 / secp256k1 |
WithNativeMints() error | Inizializza il mint del SOL nativo (wrapped-SOL) |
SetFeatureSet(*FeatureSet) error | Installa un set di feature gate |
SetComputeBudget(ComputeBudget) error | Applica un budget di calcolo |
ComputeBudget() (ComputeBudget, bool, error) | Legge il budget corrente (il bool indica "impostato esplicitamente") |
Tempo e Sysvar
| Metodo | Descrizione |
|---|---|
WarpToSlot(slot uint64) error | Salta a uno slot specifico |
Clock() (Clock, error) | Legge il sysvar Clock |
SetClock(Clock) error | Sovrascrive il sysvar Clock |
Rent() (Rent, error) | Legge il sysvar Rent |
SetRent(Rent) error | Sovrascrive il sysvar Rent |
EpochSchedule() (EpochSchedule, error) | Legge il sysvar EpochSchedule |
SetEpochSchedule(EpochSchedule) error | Sovrascrive il sysvar EpochSchedule |
EpochRewards() (EpochRewards, error) | Legge il sysvar EpochRewards |
SetEpochRewards(EpochRewards) error | Sovrascrive il sysvar EpochRewards |
LastRestartSlot() (uint64, error) | Legge il last-restart-slot |
SetLastRestartSlot(uint64) error | Imposta il last-restart-slot |
SlotHashes() ([]SlotHash, error) | Legge il sysvar SlotHashes |
SetSlotHashes([]SlotHash) error | Sovrascrive il sysvar SlotHashes |
SlotHistory() (*SlotHistory, error) | Legge il sysvar SlotHistory (handle) |
SetSlotHistory(*SlotHistory) error | Sovrascrive il sysvar SlotHistory |
StakeHistory() ([]StakeHistoryItem, error) | Legge il sysvar StakeHistory |
SetStakeHistory([]StakeHistoryItem) error | Sovrascrive il sysvar StakeHistory |
Utilità
| Metodo | Descrizione |
|---|---|
litesvm.Version() string | Stringa di versione riportata dal crate Rust sottostante litesvm |
Is this page helpful?