usolana

package
v0.0.0-...-3ec7072 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LamportsPerSOL          uint64 = 1000000000                               // 1 SOL = 1,000,000,000 Lamports
	MicroLamportsPerLamport uint64 = 1000000                                  // 1 Lamport = 1,000,000 MicroLamports
	MicroLamportsPerSOL     uint64 = MicroLamportsPerLamport * LamportsPerSOL // 1 SOL = 1,000,000,000,000 MicroLamports
	SOLDecimals             uint8  = 9
)

Variables

This section is empty.

Functions

func CreateWalletAccount

func CreateWalletAccount() (privateKeyBase58, address string, err error)

func WalletAddressFromPrivateKey

func WalletAddressFromPrivateKey(privateKeyBase58 string) (address string, err error)

Types

type ParsedInstruction

type ParsedInstruction struct {
	ProgramID         string
	TypeID            uint32                     // instruction type id
	Name              string                     // instruction name
	Accounts          []ParsedInstructionAccount // instruction input accounts
	Data              any                        // instruction input data
	InnerInstructions []ParsedInstruction
}

type ParsedInstructionAccount

type ParsedInstructionAccount struct {
	Address    string // base58
	IsWritable bool
	IsSigner   bool
}

type ParsedTx

type ParsedTx struct {
	Block                uint64   // block height // slot
	Timestamp            int64    // block timestamp // milliseconds
	TxHash               string   // transaction hash
	Status               string   // transaction status // success or fail
	Signer               []string // signer addresses
	Instructions         []ParsedInstruction
	Fee                  uint64 // transaction fee // = base fee + priority fee // lamports
	PriorityFee          uint64 // transaction priority fee // = (compute unit price * compute unit limit) / microLamportsPerLamport // lamports
	ComputeUnitsConsumed uint64 // compute units consumed
	TxVersion            int    // transaction version // -1: legacy
}

ParsedTx parsed transaction

type TxParser

type TxParser struct {
	// contains filtered or unexported fields
}

func NewDevnetTxParser

func NewDevnetTxParser() *TxParser

func NewTestnetTxParser

func NewTestnetTxParser() *TxParser

func NewTxParser

func NewTxParser(endpoint string) *TxParser

func (*TxParser) ParseBlock

func (tp *TxParser) ParseBlock(ctx context.Context, slot uint64) ([]*ParsedTx, error)

func (*TxParser) ParseLatestBlock

func (tp *TxParser) ParseLatestBlock(ctx context.Context) ([]*ParsedTx, error)

type TxPriorityFee

type TxPriorityFee struct {
	ComputeUnitLimit uint32
	ComputeUnitPrice uint64 // microLamports // 1,000,000 micro-lamports = 1 lamport
}

TxPriorityFee Transaction Priority Fee The prioritization fee is an optional fee paid to increase the chance that the current leader processes your transaction. https://solana.com/docs/core/fees#prioritization-fee

type WalletClient

type WalletClient struct {
	// contains filtered or unexported fields
}

func NewDevnetWalletClient

func NewDevnetWalletClient(privateKeyBase58 string) (*WalletClient, error)

func NewTestnetWalletClient

func NewTestnetWalletClient(privateKeyBase58 string) (*WalletClient, error)

func NewWalletClient

func NewWalletClient(endpoint, privateKeyBase58 string) (*WalletClient, error)

func (*WalletClient) GetSOLBalance

func (wc *WalletClient) GetSOLBalance(ctx context.Context) (balance uint64, err error)

func (*WalletClient) GetSOLBalanceByAddress

func (wc *WalletClient) GetSOLBalanceByAddress(ctx context.Context, address string) (balance uint64, err error)

func (*WalletClient) GetSPLTokenBalance

func (wc *WalletClient) GetSPLTokenBalance(ctx context.Context, tokenAddress string) (balance string, decimals uint8, err error)

func (*WalletClient) GetSPLTokenBalanceByAddress

func (wc *WalletClient) GetSPLTokenBalanceByAddress(ctx context.Context, tokenAddress, walletAddress string) (balance string, decimals uint8, err error)

func (*WalletClient) SimulateTxTransferSOL

func (wc *WalletClient) SimulateTxTransferSOL(ctx context.Context, toAddress string, amount uint64, priorityFeeOption ...TxPriorityFee) (unitsConsumed uint64, err error)

func (*WalletClient) SimulateTxTransferSPLToken

func (wc *WalletClient) SimulateTxTransferSPLToken(ctx context.Context, tokenAddress, toAddress string, amount uint64, priorityFeeOption ...TxPriorityFee) (unitsConsumed uint64, err error)

func (*WalletClient) TransferSOL

func (wc *WalletClient) TransferSOL(ctx context.Context, toAddress string, amount uint64, priorityFeeOption ...TxPriorityFee) (signature string, err error)

func (*WalletClient) TransferSPLToken

func (wc *WalletClient) TransferSPLToken(ctx context.Context, tokenAddress, toAddress string, amount uint64, priorityFeeOption ...TxPriorityFee) (signature string, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL