client

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo added in v1.4.0

type AccountInfo struct {
	Lamports   uint64
	Owner      common.PublicKey
	Executable bool
	RentEpoch  uint64
	Data       []byte
}

type Block added in v1.24.0

type Block struct {
	Blockhash         string
	BlockTime         *time.Time
	BlockHeight       *int64
	PreviousBlockhash string
	ParentSlot        uint64
	Transactions      []BlockTransaction
	Signatures        []string
	Rewards           []Reward
}

type BlockTransaction added in v1.24.0

type BlockTransaction struct {
	// rpc fields
	Meta        *TransactionMeta
	Transaction types.Transaction

	// custom fileds
	AccountKeys []common.PublicKey
}

type Client

type Client struct {
	RpcClient rpc.RpcClient
}

func New added in v1.19.0

func New(opts ...rpc.Option) *Client

func NewClient

func NewClient(endpoint string) *Client

func (*Client) GetAccountInfo added in v1.4.0

func (c *Client) GetAccountInfo(ctx context.Context, base58Addr string) (AccountInfo, error)

GetAccountInfo return account's info

func (*Client) GetAccountInfoAndContext added in v1.24.0

func (c *Client) GetAccountInfoAndContext(ctx context.Context, base58Addr string) (rpc.ValueWithContext[AccountInfo], error)

GetAccountInfoAndContext return account's info

func (*Client) GetAccountInfoAndContextWithConfig added in v1.24.0

func (c *Client) GetAccountInfoAndContextWithConfig(ctx context.Context, base58Addr string, cfg GetAccountInfoConfig) (rpc.ValueWithContext[AccountInfo], error)

GetAccountInfoAndContextWithConfig return account's info

func (*Client) GetAccountInfoWithConfig added in v1.11.0

func (c *Client) GetAccountInfoWithConfig(ctx context.Context, base58Addr string, cfg GetAccountInfoConfig) (AccountInfo, error)

GetAccountInfoWithConfig return account's info

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, base58Addr string) (uint64, error)

GetBalance fetch users lamports(SOL) balance

func (*Client) GetBalanceAndContext added in v1.24.0

func (c *Client) GetBalanceAndContext(ctx context.Context, base58Addr string) (rpc.ValueWithContext[uint64], error)

GetBalanceAndContext fetch users lamports(SOL) balance

func (*Client) GetBalanceAndContextWithConfig added in v1.24.0

func (c *Client) GetBalanceAndContextWithConfig(ctx context.Context, base58Addr string, cfg GetBalanceConfig) (rpc.ValueWithContext[uint64], error)

GetBalanceAndContextWithConfig fetch users lamports(SOL) balance with specific commitment

func (*Client) GetBalanceWithConfig added in v1.9.0

func (c *Client) GetBalanceWithConfig(ctx context.Context, base58Addr string, cfg GetBalanceConfig) (uint64, error)

GetBalanceWithConfig fetch users lamports(SOL) balance with specific commitment

func (*Client) GetBlock added in v1.9.0

func (c *Client) GetBlock(ctx context.Context, slot uint64) (*Block, error)

func (*Client) GetBlockTime added in v1.9.0

func (c *Client) GetBlockTime(ctx context.Context, slot uint64) (*int64, error)

GetBlockTime returns the estimated production time of a block.

func (*Client) GetBlockWithConfig added in v1.23.0

func (c *Client) GetBlockWithConfig(ctx context.Context, slot uint64, cfg GetBlockConfig) (*Block, error)

func (*Client) GetClusterNodes added in v1.10.0

func (c *Client) GetClusterNodes(ctx context.Context) ([]ClusterNode, error)

GetClusterNodes returns information about all the nodes participating in the cluster

func (*Client) GetFeeForMessage added in v1.13.0

func (c *Client) GetFeeForMessage(ctx context.Context, message types.Message) (*uint64, error)

func (*Client) GetFeeForMessageAndContext added in v1.24.0

func (c *Client) GetFeeForMessageAndContext(ctx context.Context, message types.Message) (rpc.ValueWithContext[*uint64], error)

func (*Client) GetFeeForMessageAndContextWithConfig added in v1.24.0

func (c *Client) GetFeeForMessageAndContextWithConfig(ctx context.Context, message types.Message, cfg GetFeeForMessageConfig) (rpc.ValueWithContext[*uint64], error)

func (*Client) GetFeeForMessageWithConfig added in v1.13.0

func (c *Client) GetFeeForMessageWithConfig(ctx context.Context, message types.Message, cfg GetFeeForMessageConfig) (*uint64, error)

func (*Client) GetFirstAvailableBlock added in v1.9.0

func (c *Client) GetFirstAvailableBlock(ctx context.Context) (uint64, error)

GetFirstAvailableBlock returns the slot of the lowest confirmed block that has not been purged from the ledger

func (*Client) GetGenesisHash added in v1.9.0

func (c *Client) GetGenesisHash(ctx context.Context) (string, error)

GetGenesisHash returns the genesis hash

func (*Client) GetIdentity added in v1.9.0

func (c *Client) GetIdentity(ctx context.Context) (rpc.GetIdentity, error)

GetIdentity returns the identity pubkey for the current node

func (*Client) GetLatestBlockhash added in v1.13.0

func (c *Client) GetLatestBlockhash(ctx context.Context) (rpc.GetLatestBlockhashValue, error)

GetLatestBlockhash returns the latest blockhash

func (*Client) GetLatestBlockhashAndContext added in v1.24.0

func (c *Client) GetLatestBlockhashAndContext(ctx context.Context) (rpc.ValueWithContext[rpc.GetLatestBlockhashValue], error)

GetLatestBlockhashAndContext returns the latest blockhash

func (*Client) GetLatestBlockhashAndContextWithConfig added in v1.24.0

func (c *Client) GetLatestBlockhashAndContextWithConfig(ctx context.Context, cfg GetLatestBlockhashConfig) (rpc.ValueWithContext[rpc.GetLatestBlockhashValue], error)

GetLatestBlockhashAndContextWithConfig returns the latest blockhash

func (*Client) GetLatestBlockhashWithConfig added in v1.13.0

func (c *Client) GetLatestBlockhashWithConfig(ctx context.Context, cfg GetLatestBlockhashConfig) (rpc.GetLatestBlockhashValue, error)

GetLatestBlockhash returns the latest blockhash

func (*Client) GetMinimumBalanceForRentExemption added in v1.9.0

func (c *Client) GetMinimumBalanceForRentExemption(ctx context.Context, dataLen uint64) (uint64, error)

GetMinimumBalanceForRentExemption returns minimum balance required to make account rent exempt

func (*Client) GetMinimumBalanceForRentExemptionWithConfig added in v1.24.0

func (c *Client) GetMinimumBalanceForRentExemptionWithConfig(ctx context.Context, dataLen uint64, cfg GetMinimumBalanceForRentExemptionConfig) (uint64, error)

GetMinimumBalanceForRentExemption returns minimum balance required to make account rent exempt

func (*Client) GetMultipleAccounts added in v1.13.0

func (c *Client) GetMultipleAccounts(ctx context.Context, addrs []string) ([]AccountInfo, error)

GetMultipleAccounts returns multiple accounts info

func (*Client) GetMultipleAccountsAndContext added in v1.24.0

func (c *Client) GetMultipleAccountsAndContext(ctx context.Context, addrs []string) (rpc.ValueWithContext[[]AccountInfo], error)

GetMultipleAccounts returns multiple accounts info

func (*Client) GetMultipleAccountsAndContextWithConfig added in v1.24.0

func (c *Client) GetMultipleAccountsAndContextWithConfig(ctx context.Context, addrs []string, cfg GetMultipleAccountsConfig) (rpc.ValueWithContext[[]AccountInfo], error)

GetMultipleAccountsWithConfig return account's info

func (*Client) GetMultipleAccountsWithConfig added in v1.13.0

func (c *Client) GetMultipleAccountsWithConfig(ctx context.Context, addrs []string, cfg GetMultipleAccountsConfig) ([]AccountInfo, error)

GetMultipleAccountsWithConfig return account's info

func (*Client) GetNonceAccount added in v1.16.0

func (c *Client) GetNonceAccount(ctx context.Context, base58Addr string) (system.NonceAccount, error)

func (*Client) GetNonceFromNonceAccount added in v1.16.0

func (c *Client) GetNonceFromNonceAccount(ctx context.Context, base58Addr string) (string, error)

func (*Client) GetSignatureStatus added in v1.11.0

func (c *Client) GetSignatureStatus(ctx context.Context, signature string) (*rpc.SignatureStatus, error)

func (*Client) GetSignatureStatusWithConfig added in v1.11.0

func (c *Client) GetSignatureStatusWithConfig(ctx context.Context, signature string, cfg GetSignatureStatusesConfig) (*rpc.SignatureStatus, error)

func (*Client) GetSignatureStatuses added in v1.11.0

func (c *Client) GetSignatureStatuses(ctx context.Context, signatures []string) (rpc.SignatureStatuses, error)

func (*Client) GetSignatureStatusesWithConfig added in v1.11.0

func (c *Client) GetSignatureStatusesWithConfig(ctx context.Context, signatures []string, cfg GetSignatureStatusesConfig) (rpc.SignatureStatuses, error)

func (*Client) GetSignaturesForAddress added in v1.15.0

func (c *Client) GetSignaturesForAddress(ctx context.Context, addr string) (rpc.GetSignaturesForAddress, error)

func (*Client) GetSignaturesForAddressWithConfig added in v1.15.0

func (c *Client) GetSignaturesForAddressWithConfig(ctx context.Context, addr string, cfg GetSignaturesForAddressConfig) (rpc.GetSignaturesForAddress, error)

func (*Client) GetSlot added in v1.6.0

func (c *Client) GetSlot(ctx context.Context) (uint64, error)

GetSlot get current slot (finalized)

func (*Client) GetSlotWithConfig added in v1.9.0

func (c *Client) GetSlotWithConfig(ctx context.Context, cfg GetSlotConfig) (uint64, error)

GetSlotWithConfig get slot by commitment

func (*Client) GetTokenAccount added in v1.19.0

func (c *Client) GetTokenAccount(ctx context.Context, base58Addr string) (token.TokenAccount, error)

func (*Client) GetTokenAccountBalance added in v1.8.0

func (c *Client) GetTokenAccountBalance(ctx context.Context, addr string) (TokenAmount, error)

func (*Client) GetTokenAccountBalanceAndContext added in v1.24.0

func (c *Client) GetTokenAccountBalanceAndContext(ctx context.Context, addr string) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenAccountBalanceAndContextWithConfig added in v1.24.0

func (c *Client) GetTokenAccountBalanceAndContextWithConfig(ctx context.Context, addr string, cfg GetTokenAccountBalanceConfig) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenAccountBalanceWithConfig added in v1.9.0

func (c *Client) GetTokenAccountBalanceWithConfig(ctx context.Context, addr string, cfg GetTokenAccountBalanceConfig) (TokenAmount, error)

func (*Client) GetTokenAccountsByOwnerByMint added in v1.24.0

func (c *Client) GetTokenAccountsByOwnerByMint(ctx context.Context, owner, mintAddr string) ([]token.TokenAccount, error)

func (*Client) GetTokenAccountsByOwnerByProgram added in v1.24.0

func (c *Client) GetTokenAccountsByOwnerByProgram(ctx context.Context, owner, programId string) ([]token.TokenAccount, error)

func (*Client) GetTokenAccountsByOwnerWithContextByMint added in v1.24.0

func (c *Client) GetTokenAccountsByOwnerWithContextByMint(ctx context.Context, owner, mintAddr string) (rpc.ValueWithContext[[]token.TokenAccount], error)

func (*Client) GetTokenAccountsByOwnerWithContextByProgram added in v1.24.0

func (c *Client) GetTokenAccountsByOwnerWithContextByProgram(ctx context.Context, owner, programId string) (rpc.ValueWithContext[[]token.TokenAccount], error)

func (*Client) GetTokenSupply added in v1.9.0

func (c *Client) GetTokenSupply(ctx context.Context, mintAddr string) (TokenAmount, error)

func (*Client) GetTokenSupplyAndContext added in v1.24.0

func (c *Client) GetTokenSupplyAndContext(ctx context.Context, mintAddr string) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenSupplyAndContextWithConfig added in v1.24.0

func (c *Client) GetTokenSupplyAndContextWithConfig(ctx context.Context, mintAddr string, cfg GetTokenSupplyConfig) (rpc.ValueWithContext[TokenAmount], error)

func (*Client) GetTokenSupplyWithConfig added in v1.9.0

func (c *Client) GetTokenSupplyWithConfig(ctx context.Context, mintAddr string, cfg GetTokenSupplyConfig) (TokenAmount, error)

func (*Client) GetTransaction added in v1.9.0

func (c *Client) GetTransaction(ctx context.Context, txhash string) (*Transaction, error)

GetTransaction returns transaction details for a confirmed transaction

func (*Client) GetTransactionCount added in v1.9.0

func (c *Client) GetTransactionCount(ctx context.Context) (uint64, error)

GetTransactionCount returns the current Transaction count from the ledger

func (*Client) GetTransactionCountWithConfig added in v1.9.0

func (c *Client) GetTransactionCountWithConfig(ctx context.Context, cfg GetTransactionCountConfig) (uint64, error)

GetTransactionCount returns the current Transaction count from the ledger

func (*Client) GetTransactionWithConfig added in v1.9.0

func (c *Client) GetTransactionWithConfig(ctx context.Context, txhash string, cfg GetTransactionConfig) (*Transaction, error)

GetTransaction returns transaction details for a confirmed transaction

func (*Client) GetVersion added in v1.9.0

func (c *Client) GetVersion(ctx context.Context) (rpc.GetVersion, error)

GetVersion returns the current solana versions running on the node

func (*Client) IsBlockhashValid added in v1.13.0

func (c *Client) IsBlockhashValid(ctx context.Context, blockhash string) (bool, error)

func (*Client) IsBlockhashValidAndContext added in v1.24.0

func (c *Client) IsBlockhashValidAndContext(ctx context.Context, blockhash string) (rpc.ValueWithContext[bool], error)

func (*Client) IsBlockhashValidAndContextWithConfig added in v1.24.0

func (c *Client) IsBlockhashValidAndContextWithConfig(ctx context.Context, blockhash string, cfg IsBlockhashValidConfig) (rpc.ValueWithContext[bool], error)

func (*Client) IsBlockhashValidWithConfig added in v1.13.0

func (c *Client) IsBlockhashValidWithConfig(ctx context.Context, blockhash string, cfg IsBlockhashValidConfig) (bool, error)

func (*Client) MinimumLedgerSlot added in v1.9.0

func (c *Client) MinimumLedgerSlot(ctx context.Context) (uint64, error)

MinimumLedgerSlot returns the lowest slot that the node has information about in its ledger. This value may increase over time if the node is configured to purge older ledger data

func (*Client) QuickSendTransaction deprecated added in v1.9.0

func (c *Client) QuickSendTransaction(ctx context.Context, param QuickSendTransactionParam) (string, error)

Deprecated: please use sendTransaction QuickSendTransaction is a quick way to send tx

func (*Client) RequestAirdrop added in v1.9.0

func (c *Client) RequestAirdrop(ctx context.Context, base58Addr string, lamports uint64) (string, error)

RequestAirdrop requests an airdrop of lamports to a Pubkey

func (*Client) RequestAirdropWithConfig added in v1.24.0

func (c *Client) RequestAirdropWithConfig(ctx context.Context, base58Addr string, lamports uint64, cfg RequestAirdropConfig) (string, error)

RequestAirdrop requests an airdrop of lamports to a Pubkey

func (*Client) SendTransaction added in v1.4.0

func (c *Client) SendTransaction(ctx context.Context, tx types.Transaction) (string, error)

SendTransaction send transaction struct directly

func (*Client) SendTransactionWithConfig added in v1.10.0

func (c *Client) SendTransactionWithConfig(ctx context.Context, tx types.Transaction, cfg SendTransactionConfig) (string, error)

SendTransaction send transaction struct directly

func (*Client) SimulateTransaction added in v1.11.0

func (c *Client) SimulateTransaction(ctx context.Context, tx types.Transaction) (SimulateTransaction, error)

func (*Client) SimulateTransactionAndContext added in v1.24.0

func (c *Client) SimulateTransactionAndContext(ctx context.Context, tx types.Transaction) (rpc.ValueWithContext[SimulateTransaction], error)

func (*Client) SimulateTransactionAndContextWithConfig added in v1.24.0

func (c *Client) SimulateTransactionAndContextWithConfig(ctx context.Context, tx types.Transaction, cfg SimulateTransactionConfig) (rpc.ValueWithContext[SimulateTransaction], error)

func (*Client) SimulateTransactionWithConfig added in v1.11.0

func (c *Client) SimulateTransactionWithConfig(ctx context.Context, tx types.Transaction, cfg SimulateTransactionConfig) (SimulateTransaction, error)

type ClusterNode added in v1.10.0

type ClusterNode struct {
	Pubkey       common.PublicKey
	Gossip       *string
	Tpu          *string
	Rpc          *string
	Version      *string
	FeatureSet   *uint32
	ShredVersion *uint16
}

type GetAccountInfoConfig added in v1.11.0

type GetAccountInfoConfig struct {
	Commitment rpc.Commitment
	DataSlice  *rpc.DataSlice
}

type GetBalanceConfig added in v1.24.0

type GetBalanceConfig struct {
	Commitment rpc.Commitment
}

type GetBlockConfig added in v1.24.0

type GetBlockConfig struct {
	Commitment         rpc.Commitment
	TransactionDetails rpc.GetBlockConfigTransactionDetails
	Rewards            *bool
}

type GetFeeForMessageConfig added in v1.13.0

type GetFeeForMessageConfig struct {
	Commitment rpc.Commitment
}

type GetLatestBlockhashConfig added in v1.13.0

type GetLatestBlockhashConfig struct {
	Commitment rpc.Commitment
}

type GetLatestBlockhashValue added in v1.24.0

type GetLatestBlockhashValue struct {
	Commitment rpc.Commitment
}

type GetMinimumBalanceForRentExemptionConfig added in v1.24.0

type GetMinimumBalanceForRentExemptionConfig struct {
	Commitment rpc.Commitment
}

type GetMultipleAccountsConfig added in v1.13.0

type GetMultipleAccountsConfig struct {
	Commitment rpc.Commitment
	DataSlice  *rpc.DataSlice
}

type GetSignatureStatusesConfig added in v1.24.0

type GetSignatureStatusesConfig struct {
	SearchTransactionHistory bool
}

type GetSignaturesForAddressConfig added in v1.24.0

type GetSignaturesForAddressConfig struct {
	Limit      int
	Before     string
	Until      string
	Commitment rpc.Commitment
}

type GetSlotConfig added in v1.24.0

type GetSlotConfig struct {
	Commitment rpc.Commitment
}

type GetTokenAccountBalanceConfig added in v1.24.0

type GetTokenAccountBalanceConfig struct {
	Commitment rpc.Commitment
}

type GetTokenSupplyConfig added in v1.24.0

type GetTokenSupplyConfig struct {
	Commitment rpc.Commitment
}

type GetTransactionConfig added in v1.24.0

type GetTransactionConfig struct {
	Commitment rpc.Commitment
}

type GetTransactionCountConfig added in v1.24.0

type GetTransactionCountConfig struct {
	Commitment rpc.Commitment
}

type InnerInstruction added in v1.24.0

type InnerInstruction struct {
	Index        uint64
	Instructions []types.CompiledInstruction
}

type IsBlockhashValidConfig added in v1.24.0

type IsBlockhashValidConfig struct {
	Commitment rpc.Commitment
}

type QuickSendTransactionParam added in v1.9.0

type QuickSendTransactionParam struct {
	Instructions []types.Instruction
	Signers      []types.Account
	FeePayer     common.PublicKey
}

type RequestAirdropConfig added in v1.24.0

type RequestAirdropConfig struct {
	Commitment rpc.Commitment
}

type ReturnData added in v1.23.0

type ReturnData struct {
	ProgramId common.PublicKey
	Data      []byte
}

type Reward added in v1.24.0

type Reward struct {
	Pubkey       common.PublicKey `json:"pubkey"`
	Lamports     int64            `json:"lamports"`
	PostBalances uint64           `json:"postBalance"`
	RewardType   *rpc.RewardType  `json:"rewardType"`
	Commission   *uint8           `json:"commission"`
}

type SendTransactionConfig added in v1.10.0

type SendTransactionConfig struct {
	SkipPreflight       bool
	PreflightCommitment rpc.Commitment
	MaxRetries          uint64
}

type SimulateTransaction added in v1.11.0

type SimulateTransaction struct {
	Err        any
	Logs       []string
	Accounts   []*AccountInfo
	ReturnData *ReturnData
}

type SimulateTransactionConfig added in v1.11.0

type SimulateTransactionConfig struct {
	SigVerify              bool
	Commitment             rpc.Commitment
	ReplaceRecentBlockhash bool
	Addresses              []string
}

type TokenAmount added in v1.24.0

type TokenAmount struct {
	Amount         uint64
	Decimals       uint8
	UIAmountString string
}

type Transaction added in v1.24.0

type Transaction struct {
	// rpc
	Slot        uint64
	Meta        *TransactionMeta
	Transaction types.Transaction
	BlockTime   *int64

	// custom
	AccountKeys []common.PublicKey
}

func (Transaction) Version added in v1.24.0

func (t Transaction) Version() types.MessageVersion

type TransactionMeta added in v1.9.0

type TransactionMeta struct {
	Err                  any
	Fee                  uint64
	PreBalances          []int64
	PostBalances         []int64
	PreTokenBalances     []rpc.TransactionMetaTokenBalance
	PostTokenBalances    []rpc.TransactionMetaTokenBalance
	LogMessages          []string
	InnerInstructions    []InnerInstruction
	LoadedAddresses      rpc.TransactionLoadedAddresses
	ReturnData           *ReturnData
	ComputeUnitsConsumed *uint64
}

Jump to

Keyboard shortcuts

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