solana

package
v0.0.0-...-779bc50 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommitmentFinalized = CommitmentStatus{"finalized"}
	CommitmentConfirmed = CommitmentStatus{"confirmed"}
	CommitmentProcessed = CommitmentStatus{"processed"}
)

For more information, see https://docs.solanalabs.com/consensus/commitments

Functions

func NewTransactionFromBase64

func NewTransactionFromBase64(txStr string) (solana.Transaction, error)

NewTransactionFromBase64 deserializes a transaction from a base64 string.

Types

type Client

type Client interface {
	SendTransactionOnChain(context.Context, string, rpc.CommitmentType) (TxID, error)
	CheckSignature(context.Context, TxID, rpc.ConfirmationStatusType) (bool, error)
	GetTokenAccountBalance(context.Context, string) (TokenAccount, error)
}

func NewClient

func NewClient(
	wallet Wallet,
	rpcEndpoint string,
	opts ...ClientOption,
) (Client, error)

NewClient creates a new Solana client with the given wallet and RPC endpoint. If you want to monitor your transactions using a websocket endpoint, use NewClientWithWS.

type ClientOption

type ClientOption func(*client) error

ClientOption is a function that allows to specify options for the client.

func WithClientRPC

func WithClientRPC(clientRPC rpcService) ClientOption

WithClientRPC sets the RPC service for the client.

func WithMaxRetries

func WithMaxRetries(maxRetries uint) ClientOption

WithMaxRetries sets the maximum number of retries for the engine when sending a transaction on-chain

type CommitmentStatus

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

func (CommitmentStatus) String

func (cs CommitmentStatus) String() string

type Monitor

type Monitor interface {
	WaitForCommitmentStatus(context.Context, TxID, CommitmentStatus) (MonitorResponse, error)
}

func NewMonitor

func NewMonitor(wsEndpoint string, opts ...MonitorOption) (Monitor, error)

type MonitorOption

type MonitorOption func(*monitor) error

MonitorOption is a function that allows to specify options for the monitor.

func WithMonitorSubscriber

func WithMonitorSubscriber(subscriber subscriberService) MonitorOption

WithMonitorSubscriber sets the subscriber service for the monitor.

type MonitorResponse

type MonitorResponse struct {
	// Ok is true if the transaction reached the desired commitment status.
	Ok bool
	// InstructionErr is filled if the transaction was confirmed with an error.
	InstructionErr error
}

type SubResponse

type SubResponse struct {
	Slot           uint64
	InstructionErr error
}

type TokenAccount

type TokenAccount struct {
	Amount   decimal.Decimal
	Decimals uint8
}

type TxID

type TxID string

type Wallet

type Wallet struct {
	*solana.Wallet
}

Wallet is a wrapper around a solana.Wallet

func NewWalletFromPrivateKeyBase58

func NewWalletFromPrivateKeyBase58(privateKey string) (Wallet, error)

func (Wallet) SignTransaction

func (w Wallet) SignTransaction(tx solana.Transaction) (solana.Transaction, error)

SignTransaction signs a transaction with the wallet's private key.

Jump to

Keyboard shortcuts

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