solclient

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client defines typed wrappers for the Ethereum RPC API.

func Dial

func Dial(rawurl string) (*Client, error)

Dial connects a client to the given URL.

func DialContext

func DialContext(ctx context.Context, rawurl string) (*Client, error)

DialContext connects a client to the given URL with context.

func NewClient

func NewClient(c *rpc.Client) *Client

NewClient creates a client that uses the given RPC client.

func (*Client) AccountSubscribe added in v0.0.3

func (sc *Client) AccountSubscribe(ctx context.Context, ch chan<- types.AccountNotifies, account common.Address, cfg ...types.RpcCommitmentWithEncodingCfg) (Subscription, error)

AccountSubscribe Subscribe to an account to receive notifications when the lamports or data for a given account public key changes

func (*Client) BlockSubscribe added in v0.0.3

func (sc *Client) BlockSubscribe(ctx context.Context, ch chan<- types.BlockNotifies, filter any, cfg ...types.RpcGetBlockContextCfg) (Subscription, error)

BlockSubscribe Subscribe to receive notification anytime a new block is confirmed or finalized. filter can receive: string | types.MentionsAccountProgramCfg

func (*Client) Close

func (sc *Client) Close()

Close closes the underlying RPC connection.

func (*Client) GetAccountInfo

func (sc *Client) GetAccountInfo(ctx context.Context, account common.Address, cfg ...types.RpcAccountInfoCfg) (res types.AccountInfoWithCtx, err error)

GetAccountInfo Returns all information associated with the account of provided Pubkey

func (*Client) GetBalance

func (sc *Client) GetBalance(ctx context.Context, account common.Address, cfg ...types.RpcCommitmentWithMinSlotCfg) (balance types.BalanceWithCtx, err error)

GetBalance Returns the lamport balance of the account of provided Pubkey

func (*Client) GetBlock

func (sc *Client) GetBlock(ctx context.Context, blockNum uint64, cfg ...types.RpcGetBlockContextCfg) (blockInfo types.BlockInfo, err error)

GetBlock Returns identity and transaction information about a confirmed block in the ledger

func (*Client) GetBlockCommitment

func (sc *Client) GetBlockCommitment(ctx context.Context, blockNum uint64) (blockCmt types.BlockCommitment, err error)

GetBlockCommitment Returns commitment for particular block

func (*Client) GetBlockHeight

func (sc *Client) GetBlockHeight(ctx context.Context, cfg ...types.RpcCommitmentWithMinSlotCfg) (res uint64, err error)

GetBlockHeight Returns the current block height of the node

func (*Client) GetBlockProduction

func (sc *Client) GetBlockProduction(ctx context.Context, cfg ...types.RpcGetBlockProduction) (res types.BlockProductionWithCtx, err error)

GetBlockProduction Returns recent block production information from the current or previous epoch.

func (*Client) GetBlockTime

func (sc *Client) GetBlockTime(ctx context.Context, blockNum uint64) (res int64, err error)

GetBlockTime Returns the estimated production time of a block.

func (*Client) GetBlocks

func (sc *Client) GetBlocks(ctx context.Context, startSlot uint64, args ...interface{}) (res []uint64, err error)

GetBlocks Returns a list of confirmed blocks between two slots

func (*Client) GetBlocksWithLimit

func (sc *Client) GetBlocksWithLimit(ctx context.Context, startSlot, limit uint64, cfg ...types.RpcCommitmentCfg) (res []uint64, err error)

GetBlocksWithLimit Returns a list of confirmed blocks starting at the given slot

func (*Client) GetClusterNodes

func (sc *Client) GetClusterNodes(ctx context.Context) (res []types.ClusterInformation, err error)

GetClusterNodes Returns information about all the nodes participating in the cluster

func (*Client) GetEpochInfo

func (sc *Client) GetEpochInfo(ctx context.Context, cfg ...types.RpcCommitmentWithMinSlotCfg) (res types.EpochInformation, err error)

GetEpochInfo Returns information about the current epoch

func (*Client) GetEpochSchedule

func (sc *Client) GetEpochSchedule(ctx context.Context) (res types.EpochSchedule, err error)

GetEpochSchedule Returns information about the current epoch

func (*Client) GetFeeForMessage

func (sc *Client) GetFeeForMessage(ctx context.Context, msg string, cfg ...types.RpcCommitmentWithMinSlotCfg) (res types.U64ValueWithCtx, err error)

GetFeeForMessage Get the fee the network will charge for a particular Message

func (*Client) GetFirstAvailableBlock

func (sc *Client) GetFirstAvailableBlock(ctx context.Context) (res uint64, err error)

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

func (*Client) GetGenesisHash

func (sc *Client) GetGenesisHash(ctx context.Context) (res common.Hash, err error)

GetGenesisHash Returns the genesis hash

func (*Client) GetHealth

func (sc *Client) GetHealth(ctx context.Context) (res string, err error)

GetHealth Returns the current health of the node. A healthy node is one that is within HEALTH_CHECK_SLOT_DISTANCE slots of the latest cluster confirmed slot.

func (*Client) GetHighestSnapshotSlot

func (sc *Client) GetHighestSnapshotSlot(ctx context.Context) (res types.HighestSnapshotSlot, err error)

GetHighestSnapshotSlot Returns the highest slot information that the node has snapshots for. This will find the highest full snapshot slot, and the highest incremental snapshot slot based on the full snapshot slot, if there is one.

func (*Client) GetIdentity

func (sc *Client) GetIdentity(ctx context.Context) (res types.Identity, err error)

GetIdentity Returns the identity pubkey for the current node

func (*Client) GetInflationGovernor

func (sc *Client) GetInflationGovernor(ctx context.Context, cfg ...types.RpcCommitmentCfg) (res types.InflationGovernor, err error)

GetInflationGovernor Returns the current inflation governor

func (*Client) GetInflationRate

func (sc *Client) GetInflationRate(ctx context.Context) (res types.InflationRate, err error)

GetInflationRate Returns the specific inflation values for the current epoch

func (*Client) GetInflationReward

func (sc *Client) GetInflationReward(ctx context.Context, args ...interface{}) (res []types.InflationReward, err error)

GetInflationReward Returns the inflation / staking reward for a list of addresses for an epoch

func (*Client) GetLargestAccounts

func (sc *Client) GetLargestAccounts(ctx context.Context, cfg ...types.RpcCommitmentWithFilter) (res types.AccountWithLamport, err error)

GetLargestAccounts Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours)

func (*Client) GetLatestBlockhash

func (sc *Client) GetLatestBlockhash(ctx context.Context, cfg ...types.RpcCommitmentWithMinSlotCfg) (res types.LastBlockWithCtx, err error)

GetLatestBlockhash Returns the latest blockhash

func (*Client) GetLeaderSchedule

func (sc *Client) GetLeaderSchedule(ctx context.Context, args ...interface{}) (res map[string][]uint64, err error)

GetLeaderSchedule Returns the leader schedule for an epoch --> args [slot:u64]

func (*Client) GetMaxRetransmitSlot

func (sc *Client) GetMaxRetransmitSlot(ctx context.Context) (res uint64, err error)

GetMaxRetransmitSlot Get the max slot seen from retransmit stage.

func (*Client) GetMaxShredInsertSlot

func (sc *Client) GetMaxShredInsertSlot(ctx context.Context) (res uint64, err error)

GetMaxShredInsertSlot Get the max slot seen from after shred insert.

func (*Client) GetMinimumBalanceForRentExemption

func (sc *Client) GetMinimumBalanceForRentExemption(ctx context.Context, args ...interface{}) (res uint64, err error)

GetMinimumBalanceForRentExemption Returns minimum balance required to make account rent exempt.

func (*Client) GetMultipleAccounts

func (sc *Client) GetMultipleAccounts(ctx context.Context, accounts []common.Address, cfg ...types.RpcAccountInfoCfg) (res types.AccountsInfoWithCtx, err error)

GetMultipleAccounts Returns the account information for a list of Pubkeys.

func (*Client) GetProgramAccounts

func (sc *Client) GetProgramAccounts(ctx context.Context, program common.Address, cfg ...types.RpcCombinedCfg) (res []types.ProgramAccount, err error)

GetProgramAccounts Returns all accounts owned by the provided program Pubkey

func (*Client) GetRecentPerformanceSamples

func (sc *Client) GetRecentPerformanceSamples(ctx context.Context, args ...uint64) (res []types.RpcPerfSample, err error)

GetRecentPerformanceSamples Returns a list of recent performance samples, in reverse slot order. Performance samples are taken every 60 seconds and include the number of transactions and slots that occur in a given time window.

func (*Client) GetRecentPrioritizationFees

func (sc *Client) GetRecentPrioritizationFees(ctx context.Context, args ...interface{}) (res []types.RpcPrioritizationFee, err error)

GetRecentPrioritizationFees Returns a list of prioritization fees from recent blocks.

func (*Client) GetSignatureStatuses

func (sc *Client) GetSignatureStatuses(ctx context.Context, signatures []common.Signature, cfg ...types.RpcSearchTxHistoryCfg) (res types.SignatureStatusWithCtx, err error)

GetSignatureStatuses Returns the statuses of a list of signatures. Each signature must be a txid, the first signature of a transaction.

func (*Client) GetSignaturesForAddress

func (sc *Client) GetSignaturesForAddress(ctx context.Context, account common.Address, cfg ...types.RpcSignaturesForAddressCfg) (res []types.SignatureInfo, err error)

GetSignaturesForAddress Returns signatures for confirmed transactions that include the given address in their accountKeys list. Returns signatures backwards in time from the provided signature or most recent confirmed block

func (*Client) GetSlot

func (sc *Client) GetSlot(ctx context.Context, cfg ...types.RpcCommitmentWithMinSlotCfg) (res uint64, err error)

GetSlot Returns the slot that has reached the given or default commitment level https://solana.com/docs/rpc#configuring-state-commitment

func (*Client) GetSlotLeader

func (sc *Client) GetSlotLeader(ctx context.Context, cfg ...types.RpcCommitmentWithMinSlotCfg) (res common.Address, err error)

GetSlotLeader Returns the current slot leader

func (*Client) GetSlotLeaders

func (sc *Client) GetSlotLeaders(ctx context.Context, args ...uint64) (res []common.Address, err error)

GetSlotLeaders Returns the slot leaders for a given slot range

func (*Client) GetStakeActivation

func (sc *Client) GetStakeActivation(ctx context.Context, account common.Address, cfg ...types.RpcCommitmentWithMinSlotCfg) (res types.StakeActivation, err error)

GetStakeActivation Returns epoch activation information for a stake account

func (*Client) GetStakeMinimumDelegation

func (sc *Client) GetStakeMinimumDelegation(ctx context.Context, cfg ...types.RpcCommitmentCfg) (res types.U64ValueWithCtx, err error)

GetStakeMinimumDelegation Returns the stake minimum delegation, in lamports.

func (*Client) GetSupply

func (sc *Client) GetSupply(ctx context.Context, cfg ...types.RpcSupplyCfg) (res types.SupplyWithCtx, err error)

GetSupply Returns information about the current supply.

func (*Client) GetTokenAccountBalance

func (sc *Client) GetTokenAccountBalance(ctx context.Context, account common.Address, cfg ...types.RpcCommitmentCfg) (res types.TokenAccountWithCtx, err error)

GetTokenAccountBalance Returns the token balance of an SPL Token account.

func (*Client) GetTokenAccountsByDelegate

func (sc *Client) GetTokenAccountsByDelegate(ctx context.Context, delegate common.Address, mintProg types.RpcMintWithProgramID, cfg ...types.RpcAccountInfoCfg) (res types.TokenAccountsWithCtx, err error)

GetTokenAccountsByDelegate Returns all SPL Token accounts by approved Delegate.

func (*Client) GetTokenAccountsByOwner

func (sc *Client) GetTokenAccountsByOwner(ctx context.Context, owner common.Address, program types.RpcMintWithProgramID, cfg ...types.RpcAccountInfoCfg) (res types.TokenAccountsWithCtx, err error)

GetTokenAccountsByOwner Returns all SPL Token accounts by token owner.

func (*Client) GetTokenLargestAccounts

func (sc *Client) GetTokenLargestAccounts(ctx context.Context, splToken common.Address, cfg ...types.RpcCommitmentCfg) (res types.TokenLargestHolders, err error)

GetTokenLargestAccounts Returns the 20 largest accounts of a particular SPL Token type.

func (*Client) GetTokenSupply

func (sc *Client) GetTokenSupply(ctx context.Context, splToken common.Address, cfg ...types.RpcCommitmentCfg) (res types.TokenAccountWithCtx, err error)

GetTokenSupply Returns the total supply of an SPL Token type.

func (*Client) GetTransaction

func (sc *Client) GetTransaction(ctx context.Context, signature common.Signature, cfg ...types.RpcGetTransactionCfg) (res types.TransactionInfo, err error)

GetTransaction Returns transaction details for a confirmed transaction

func (*Client) GetTransactionCount

func (sc *Client) GetTransactionCount(ctx context.Context, cfg ...types.RpcCommitmentWithMinSlotCfg) (res uint64, err error)

GetTransactionCount Returns the current Transaction count from the ledger

func (*Client) GetVersion

func (sc *Client) GetVersion(ctx context.Context) (res types.SolVersion, err error)

GetVersion Returns the current Solana version running on the node

func (*Client) GetVoteAccounts

func (sc *Client) GetVoteAccounts(ctx context.Context, cfg ...types.RpcVoteAccountCfg) (res types.RpcVoteAccounts, err error)

GetVoteAccounts Returns the account info and associated stake for all the voting accounts in the current bank.

func (*Client) IsBlockHashValid

func (sc *Client) IsBlockHashValid(ctx context.Context, hash common.Hash, cfg ...types.RpcCommitmentWithMinSlotCfg) (res bool, err error)

IsBlockHashValid Returns whether a blockHash is still valid or not

func (*Client) LogsSubscribe added in v0.0.3

func (sc *Client) LogsSubscribe(ctx context.Context, ch chan<- types.LogsNotifies, mentions any, cfg ...types.RpcCommitmentCfg) (Subscription, error)

LogsSubscribe Subscribe to transaction logging mentions can receive: string | types.MentionsCfg

func (*Client) MinimumLedgerSlot

func (sc *Client) MinimumLedgerSlot(ctx context.Context) (res uint64, err error)

MinimumLedgerSlot Returns the lowest slot that the node has information about in its ledger.

func (*Client) ProgramSubscribe added in v0.0.3

func (sc *Client) ProgramSubscribe(ctx context.Context, ch chan<- types.ProgramNotifies, address common.Address, cfg ...types.RpcCommitmentCfg) (Subscription, error)

ProgramSubscribe to a program to receive notifications when the lamports or data for an account owned by the given program changes

func (*Client) RequestAirdrop

func (sc *Client) RequestAirdrop(ctx context.Context, address common.Address, lamport *big.Int) (res common.Signature, err error)

RequestAirdrop Requests an airdrop of lamports to a Pubkey

func (*Client) SendTransaction

func (sc *Client) SendTransaction(ctx context.Context, signedTx common.Base58, cfg ...types.RpcSendTxCfg) (res common.Signature, err error)

SendTransaction Submits a signed transaction to the cluster for processing. This method does not alter the transaction in any way; it relays the transaction created by clients to the node as-is. If the node's rpc service receives the transaction, this method immediately succeeds, without waiting for any confirmations. A successful response from this method does not guarantee the transaction is processed or confirmed by the cluster. While the rpc service will reasonably retry to submit it, the transaction could be rejected if transaction's recent_blockhash expires before it lands. Use getSignatureStatuses to ensure a transaction is processed and confirmed. Before submitting, the following preflight checks are performed: The transaction signatures are verified The transaction is simulated against the bank slot specified by the preflight commitment. On failure an error will be returned. Preflight checks may be disabled if desired. It is recommended to specify the same commitment and preflight commitment to avoid confusing behavior. The returned signature is the first signature in the transaction, which is used to identify the transaction (transaction id). This identifier can be easily extracted from the transaction data before submission.

func (*Client) SetDebug added in v0.0.5

func (sc *Client) SetDebug(isDebug bool)

SetDebug set solClient debug

func (*Client) SignatureSubscribe added in v0.0.3

func (sc *Client) SignatureSubscribe(ctx context.Context, ch chan<- types.SignatureNotifies, signature common.Signature, cfg ...types.RpcCommitmentCfg) (Subscription, error)

SignatureSubscribe Subscribe to receive a notification when the transaction with the given signature reaches the specified commitment level.

func (*Client) SimulateTransaction

func (sc *Client) SimulateTransaction(ctx context.Context, signedTx common.Base58) (res map[string]interface{}, err error)

SimulateTransaction Simulate sending a transaction

func (*Client) SlotSubscribe added in v0.0.3

func (sc *Client) SlotSubscribe(ctx context.Context, ch chan<- types.SlotNotifies) (Subscription, error)

SlotSubscribe Subscribe to receive notification anytime a slot is processed by the validator

type Subscription added in v0.0.7

type Subscription interface {
	// Unsubscribe cancels the sending of events to the data channel
	// and closes the error channel.
	Unsubscribe()
	// Err returns the subscription error channel. The error channel receives
	// a value if there is an issue with the subscription (e.g. the network connection
	// delivering the events has been closed). Only one value will ever be sent.
	// The error channel is closed by Unsubscribe.
	Err() <-chan error
}

Subscription represents an event subscription where events are delivered on a data channel.

Jump to

Keyboard shortcuts

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