rpc

package
v1.23.11 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalnetRPCEndpoint = "http://localhost:8899"
	DevnetRPCEndpoint   = "https://api.devnet.solana.com"
	TestnetRPCEndpoint  = "https://api.testnet.solana.com"
	MainnetRPCEndpoint  = "https://api.mainnet-beta.solana.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountEncoding

type AccountEncoding string
const (
	AccountEncodingBase58     AccountEncoding = "base58"
	AccountEncodingJsonParsed AccountEncoding = "jsonParsed"
	AccountEncodingBase64     AccountEncoding = "base64"
	AccountEncodingBase64Zstd AccountEncoding = "base64+zstd"
)

type AccountInfo

type AccountInfo struct {
	Lamports   uint64 `json:"lamports"`
	Owner      string `json:"owner"`
	RentEpoch  uint64 `json:"rentEpoch"`
	Data       any    `json:"data"`
	Executable bool   `json:"executable"`
}

type Commitment

type Commitment string

Commitment describes how finalized a block is at that point in time

const (
	CommitmentFinalized Commitment = "finalized"
	CommitmentConfirmed Commitment = "confirmed"
	CommitmentProcessed Commitment = "processed"
)

type Context

type Context struct {
	Slot       uint64 `json:"slot"`
	ApiVersion string `json:"apiVersion,omitempty"`
}

type DataSlice

type DataSlice struct {
	Offset uint64 `json:"offset"`
	Length uint64 `json:"length"`
}

type GetAccountInfo

type GetAccountInfo ValueWithContext[AccountInfo]

type GetAccountInfoConfig

type GetAccountInfoConfig struct {
	Commitment Commitment      `json:"commitment,omitempty"`
	Encoding   AccountEncoding `json:"encoding,omitempty"`
	DataSlice  *DataSlice      `json:"dataSlice,omitempty"`
}

GetAccountInfoConfig is an option config for `getAccountInfo`

type GetAccountResponse

type GetAccountResponse JsonRpcResponse[GetAccountInfo]

type GetBalance

type GetBalance ValueWithContext[uint64]

type GetBalanceConfig

type GetBalanceConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetBalanceConfig is a option config for `getBalance`

type GetBalanceResponse

type GetBalanceResponse JsonRpcResponse[GetBalance]

type GetBlock

type GetBlock struct {
	Blockhash         string                `json:"blockhash"`
	BlockTime         *int64                `json:"blockTime"`
	BlockHeight       *int64                `json:"blockHeight"`
	PreviousBlockhash string                `json:"previousBlockhash"`
	ParentSlot        uint64                `json:"parentSlot"`
	Transactions      []GetBlockTransaction `json:"transactions"`
	Signatures        []string              `json:"signatures"`
	Rewards           []GetBlockReward      `json:"rewards"`
}

type GetBlockCommitment

type GetBlockCommitment struct {
	Commitment *[]uint64 `json:"commitment"`
	TotalStake uint64    `json:"totalStake"`
}

GetBlockCommitmentResult is a part of raw rpc response of `getBlockCommitment`

type GetBlockCommitmentResponse

type GetBlockCommitmentResponse JsonRpcResponse[GetBlockCommitment]

type GetBlockConfig

type GetBlockConfig struct {
	Encoding                       GetBlockConfigEncoding           `json:"encoding,omitempty"`                       // default: "json"
	TransactionDetails             GetBlockConfigTransactionDetails `json:"transactionDetails,omitempty"`             // default: "full", either "full", "signatures", "none"
	Rewards                        *bool                            `json:"rewards,omitempty"`                        // default: true
	Commitment                     Commitment                       `json:"commitment,omitempty"`                     // "processed" is not supported
	MaxSupportedTransactionVersion *uint8                           `json:"maxSupportedTransactionVersion,omitempty"` // default: nil legacy only
}

type GetBlockConfigEncoding

type GetBlockConfigEncoding string
const (
	GetBlockConfigEncodingJson       GetBlockConfigEncoding = "json"
	GetBlockConfigEncodingJsonParsed GetBlockConfigEncoding = "jsonParsed"
	GetBlockConfigEncodingBase58     GetBlockConfigEncoding = "base58"
	GetBlockConfigEncodingBase64     GetBlockConfigEncoding = "base64"
)

type GetBlockConfigTransactionDetails

type GetBlockConfigTransactionDetails string
const (
	GetBlockConfigTransactionDetailsFull       GetBlockConfigTransactionDetails = "full"
	GetBlockConfigTransactionDetailsSignatures GetBlockConfigTransactionDetails = "signatures"
	GetBlockConfigTransactionDetailsNone       GetBlockConfigTransactionDetails = "none"
)

type GetBlockHeightConfig

type GetBlockHeightConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetBlockHeightConfig is a option config for `getBlockHeight`

type GetBlockHeightResponse

type GetBlockHeightResponse JsonRpcResponse[uint64]

type GetBlockProductionConfig

type GetBlockProductionConfig struct {
	Commitment Commitment               `json:"commitment,omitempty"`
	Range      *GetBlockProductionRange `json:"range,omitempty"`
	Identity   string                   `json:"identity,omitempty"`
}

GetBlockProductionConfig is a option config for `getBlockProduction`

type GetBlockProductionRange

type GetBlockProductionRange struct {
	FirstSlot uint64 `json:"firstSlot"`
	LastSlot  uint64 `json:"lastSlot,omitempty"`
}

type GetBlockProductionResponse

type GetBlockProductionResponse JsonRpcResponse[GetBlockProduction]

type GetBlockProductionResponseResultValue

type GetBlockProductionResponseResultValue struct {
	ByIdentity map[string][]uint64     `json:"byIdentity"`
	Range      GetBlockProductionRange `json:"range"`
}

type GetBlockResponse

type GetBlockResponse JsonRpcResponse[GetBlock]

type GetBlockReward

type GetBlockReward struct {
	Pubkey       string             `json:"pubkey"`
	Lamports     int64              `json:"lamports"`
	PostBalances uint64             `json:"postBalance"`
	RewardType   GetBlockRewardType `json:"rewardType"`
	Commission   *uint8             `json:"commission"`
}

type GetBlockRewardType

type GetBlockRewardType string
const (
	GetBlockRewardTypeNone    GetBlockRewardType = ""
	GetBlockRewardTypeFee     GetBlockRewardType = "fee"
	GetBlockRewardTypeRent    GetBlockRewardType = "rent"
	GetBlockRewardTypeVoting  GetBlockRewardType = "voting"
	GetBlockRewardTypeStaking GetBlockRewardType = "staking"
)

type GetBlockTimeResponse

type GetBlockTimeResponse JsonRpcResponse[*int64]

type GetBlockTransaction

type GetBlockTransaction struct {
	Transaction any              `json:"transaction"`
	Meta        *TransactionMeta `json:"meta"`
	Version     any              `json:"version"`
}

type GetBlocksConfig

type GetBlocksConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetBlocksConfig is a option config for `getBlocks`

type GetBlocksResponse

type GetBlocksResponse JsonRpcResponse[[]uint64]

type GetBlocksWithLimitConfig

type GetBlocksWithLimitConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetBlocksWithLimitConfig is a option config for `getBlocksWithLimit`

type GetBlocksWithLimitResponse

type GetBlocksWithLimitResponse JsonRpcResponse[[]uint64]

type GetClusterNode

type GetClusterNode struct {
	Pubkey       string
	Gossip       *string
	Tpu          *string
	Rpc          *string
	Version      *string
	FeatureSet   *uint32
	ShredVersion *uint16
}

type GetClusterNodes

type GetClusterNodes []GetClusterNode

type GetClusterNodesResponse

type GetClusterNodesResponse JsonRpcResponse[GetClusterNodes]

type GetEpochInfo

type GetEpochInfo struct {
	AbsoluteSlot     uint64  `json:"absoluteSlot"`
	BlockHeight      uint64  `json:"blockHeight"`
	Epoch            uint64  `json:"epoch"`
	SlotIndex        uint64  `json:"slotIndex"`
	SlotsInEpoch     uint64  `json:"slotsInEpoch"`
	TransactionCount *uint64 `json:"transactionCount"`
}

type GetEpochInfoConfig

type GetEpochInfoConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetEpochInfoConfig is a option config for `getEpochInfo`

type GetEpochInfoResponse

type GetEpochInfoResponse JsonRpcResponse[GetEpochInfo]

type GetEpochSchedule

type GetEpochSchedule struct {
	FirstNormalEpoch         uint64 `json:"firstNormalEpoch"`
	FirstNormalSlot          uint64 `json:"firstNormalSlot"`
	LeaderScheduleSlotOffset uint64 `json:"leaderScheduleSlotOffset"`
	SlotsPerEpoch            uint64 `json:"slotsPerEpoch"`
	Warmup                   bool   `json:"warmup"`
}

type GetEpochScheduleResponse

type GetEpochScheduleResponse JsonRpcResponse[GetEpochSchedule]

type GetFeeForMessage

type GetFeeForMessage ValueWithContext[*uint64]

type GetFeeForMessageConfig

type GetFeeForMessageConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetFeeForMessageConfig is a option config for `GetFeeForMessage`

type GetFeeForMessageResponse

type GetFeeForMessageResponse JsonRpcResponse[ValueWithContext[*uint64]]

type GetFirstAvailableBlockResponse

type GetFirstAvailableBlockResponse JsonRpcResponse[uint64]

type GetGenesisHashResponse

type GetGenesisHashResponse JsonRpcResponse[string]

type GetIdentity

type GetIdentity struct {
	Identity string `json:"identity"`
}

type GetIdentityResponse

type GetIdentityResponse JsonRpcResponse[GetIdentity]

type GetInflationGovernor

type GetInflationGovernor struct {
	Foundation     float64 `json:"foundation"`
	FoundationTerm float64 `json:"foundationTerm"`
	Initial        float64 `json:"initial"`
	Taper          float64 `json:"taper"`
	Terminal       float64 `json:"terminal"`
}

type GetInflationGovernorConfig

type GetInflationGovernorConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetInflationGovernorConfig is a option config for `getInflationGovernor`

type GetInflationGovernorResponse

type GetInflationGovernorResponse JsonRpcResponse[GetInflationGovernor]

type GetInflationRate

type GetInflationRate struct {
	Epoch      uint64  `json:"epoch"`
	Foundation float64 `json:"foundation"`
	Total      float64 `json:"total"`
	Validator  float64 `json:"validator"`
}

type GetInflationRateResponse

type GetInflationRateResponse JsonRpcResponse[GetInflationRate]

type GetInflationReward

type GetInflationReward struct {
	Epoch         uint64 `json:"epoch"`
	EffectiveSlot uint64 `json:"effectiveSlot"`
	Amount        uint64 `json:"amount"`
	PostBalance   uint64 `json:"postBalance"`
	Commission    *uint8 `json:"commission"`
}

GetInflationRewardResult is a part of raw rpc response of `getInflationReward`

type GetInflationRewardConfig

type GetInflationRewardConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
	Epoch      uint64     `json:"epoch,omitempty"`
}

GetInflationRewardConfig is a option config for `getInflationReward`

type GetInflationRewardResponse

type GetInflationRewardResponse JsonRpcResponse[[]*GetInflationReward]

type GetLatestBlockhashConfig

type GetLatestBlockhashConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetLatestBlockhashConfig is a option config for `getLatestBlockhash`

type GetLatestBlockhashResponse

type GetLatestBlockhashResponse JsonRpcResponse[GetLatestBlockhash]

type GetLatestBlockhashValue

type GetLatestBlockhashValue struct {
	Blockhash              string `json:"blockhash"`
	LatestValidBlockHeight uint64 `json:"lastValidBlockHeight"`
}

GetLatestBlockhashResult is a part of raw rpc response of `getLatestBlockhash`

type GetMinimumBalanceForRentExemptionConfig

type GetMinimumBalanceForRentExemptionConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

type GetMinimumBalanceForRentExemptionResponse

type GetMinimumBalanceForRentExemptionResponse JsonRpcResponse[uint64]

type GetMultipleAccounts

type GetMultipleAccounts ValueWithContext[[]AccountInfo]

type GetMultipleAccountsConfig

type GetMultipleAccountsConfig struct {
	Commitment Commitment      `json:"commitment,omitempty"`
	Encoding   AccountEncoding `json:"encoding,omitempty"`
	DataSlice  *DataSlice      `json:"dataSlice,omitempty"`
}

GetMultipleAccountsConfig is an option config for `getAccountInfo`

type GetMultipleAccountsConfigEncoding

type GetMultipleAccountsConfigEncoding string

GetMultipleAccountsConfigEncoding is account's data encode format

type GetMultipleAccountsResponse

type GetMultipleAccountsResponse JsonRpcResponse[GetMultipleAccounts]

type GetProgramAccount

type GetProgramAccount struct {
	Pubkey  string      `json:"pubkey"`
	Account AccountInfo `json:"account"`
}

type GetProgramAccounts

type GetProgramAccounts []GetProgramAccount

type GetProgramAccountsConfig

type GetProgramAccountsConfig struct {
	Encoding   AccountEncoding                  `json:"encoding,omitempty"`
	Commitment Commitment                       `json:"commitment,omitempty"`
	DataSlice  *DataSlice                       `json:"dataSlice,omitempty"`
	Filters    []GetProgramAccountsConfigFilter `json:"filters,omitempty"`
}

GetProgramAccountsConfig is a option config for `getProgramAccounts`

type GetProgramAccountsConfigFilter

type GetProgramAccountsConfigFilter struct {
	MemCmp   *GetProgramAccountsConfigFilterMemCmp `json:"memcmp,omitempty"`
	DataSize uint64                                `json:"dataSize,omitempty"`
}

GetProgramAccountsConfigFilter you can set either MemCmp or DataSize but can be both, if needed, separate them into two

type GetProgramAccountsConfigFilterMemCmp

type GetProgramAccountsConfigFilterMemCmp struct {
	Offset uint64 `json:"offset"`
	Bytes  string `json:"bytes"`
}

type GetProgramAccountsResponse

type GetProgramAccountsResponse JsonRpcResponse[GetProgramAccounts]

type GetProgramAccountsWithContext

type GetProgramAccountsWithContext ValueWithContext[GetProgramAccounts]

type GetSignatureStatuses

type GetSignatureStatuses ValueWithContext[SignatureStatuses]

type GetSignatureStatusesConfig

type GetSignatureStatusesConfig struct {
	SearchTransactionHistory bool `json:"searchTransactionHistory,omitempty"`
}

GetSignatureStatusesConfig is a option config for `getSignatureStatuses`

type GetSignatureStatusesResponse

type GetSignatureStatusesResponse JsonRpcResponse[GetSignatureStatuses]

type GetSignaturesForAddress

type GetSignaturesForAddress []SignatureWithStatus

type GetSignaturesForAddressConfig

type GetSignaturesForAddressConfig struct {
	Limit      int        `json:"limit,omitempty"` // between 1 and 1000, default: 1000
	Before     string     `json:"before,omitempty"`
	Until      string     `json:"until,omitempty"`
	Commitment Commitment `json:"commitment,omitempty"` // "processed" is not supported, default is "finalized"
}

GetSignaturesForAddressConfig is option config of `getSignaturesForAddress`

type GetSignaturesForAddressResponse

type GetSignaturesForAddressResponse JsonRpcResponse[GetSignaturesForAddress]

type GetSlotConfig

type GetSlotConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetSlotConfig is a option config for `getSlot`

type GetSlotResponse

type GetSlotResponse JsonRpcResponse[uint64]

type GetTokenAccountBalanceConfig

type GetTokenAccountBalanceConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

type GetTokenAccountsByOwner

type GetTokenAccountsByOwner ValueWithContext[GetProgramAccounts]

type GetTokenAccountsByOwnerConfig

type GetTokenAccountsByOwnerConfig struct {
	Commitment Commitment      `json:"commitment,omitempty"`
	Encoding   AccountEncoding `json:"encoding,omitempty"`
	DataSlice  *DataSlice      `json:"dataSlice,omitempty"`
}

GetTokenAccountsByOwnerConfig is a option config for `GetTokenAccountsByOwner`

type GetTokenAccountsByOwnerConfigFilter

type GetTokenAccountsByOwnerConfigFilter struct {
	Mint      string `json:"mint,omitempty"`
	ProgramId string `json:"programId,omitempty"`
}

GetTokenAccountsByOwnerConfigFilter either mint or programId

type GetTokenAccountsByOwnerResponse

type GetTokenAccountsByOwnerResponse JsonRpcResponse[GetTokenAccountsByOwner]

type GetTokenSupplyConfig

type GetTokenSupplyConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetTokenSupplyConfig is option config of `getTokenSupply`

type GetTokenSupplyResponse

type GetTokenSupplyResponse JsonRpcResponse[GetTokenSupply]

type GetTokenSupplyResultValue

type GetTokenSupplyResultValue struct {
	Amount         string `json:"amount"`
	Decimals       uint8  `json:"decimals"`
	UIAmountString string `json:"uiAmountString"`
}

GetTokenSupplyResultValue is a part of `getTokenSupply` raw response

type GetTransaction

type GetTransaction struct {
	Slot        uint64           `json:"slot"`
	Meta        *TransactionMeta `json:"meta"`
	Transaction any              `json:"transaction"`
	BlockTime   *int64           `json:"blockTime"`
	Version     any              `json:"version,omitempty"`
}

GetTransaction is a part of GetTransactionResponse

type GetTransactionConfig

type GetTransactionConfig struct {
	Encoding                       TransactionEncoding `json:"encoding,omitempty"`
	Commitment                     Commitment          `json:"commitment,omitempty"`                     // "processed" is not supported
	MaxSupportedTransactionVersion *uint8              `json:"maxSupportedTransactionVersion,omitempty"` // default: nil legacy only
}

GetTransactionConfig is a option config for `getTransaction`

type GetTransactionCountConfig

type GetTransactionCountConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

GetTransactionCountConfig is a option config for `getTransactionCount`

type GetTransactionCountResponse

type GetTransactionCountResponse JsonRpcResponse[uint64]

type GetTransactionResponse

type GetTransactionResponse JsonRpcResponse[*GetTransaction]

type GetVersion

type GetVersion struct {
	SolanaCore string  `json:"solana-core"`
	FeatureSet *uint32 `json:"feature-set"`
}

GetVersionResult is a part of raw rpc response of `getVersion`

type GetVersionResponse

type GetVersionResponse JsonRpcResponse[GetVersion]

type GetVoteAccounts

type GetVoteAccounts struct {
	Current   VoteAccounts `json:"current"`
	Deliquent VoteAccounts `json:"delinquent"`
}

type GetVoteAccountsConfig

type GetVoteAccountsConfig struct {
	Commitment              Commitment `json:"commitment,omitempty"`
	VotePubkey              string     `json:"votePubkey,omitempty"`
	KeepUnstakedDelinquents bool       `json:"keepUnstakedDelinquents,omitempty"`
	DelinquentSlotDistance  uint64     `json:"delinquentSlotDistance,omitempty"`
}

type GetVoteAccountsResponse

type GetVoteAccountsResponse JsonRpcResponse[GetVoteAccounts]

type Instruction

type Instruction struct {
	ProgramIDIndex int    `json:"programIdIndex"`
	Accounts       []int  `json:"accounts"`
	Data           string `json:"data"`
}

Instruction is a part of TransactionMetaInnerInstruction

type IsBlockhashValid

type IsBlockhashValid ValueWithContext[bool]

type IsBlockhashValidConfig

type IsBlockhashValidConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

IsBlockhashValidConfig is a option config for `IsBlockhashValid`

type IsBlockhashValidResponse

type IsBlockhashValidResponse JsonRpcResponse[IsBlockhashValid]

type JsonRpcError

type JsonRpcError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

func (*JsonRpcError) Error

func (e *JsonRpcError) Error() string

type JsonRpcRequest

type JsonRpcRequest struct {
	JsonRpc string `json:"jsonrpc"`
	Id      uint64 `json:"id"`
	Method  string `json:"method"`
	Params  []any  `json:"params,omitempty"`
}

type JsonRpcResponse

type JsonRpcResponse[T any] struct {
	JsonRpc string        `json:"jsonrpc"`
	Id      uint64        `json:"id"`
	Result  T             `json:"result"`
	Error   *JsonRpcError `json:"error,omitempty"`
}

func (JsonRpcResponse[T]) GetError added in v1.23.8

func (j JsonRpcResponse[T]) GetError() error

func (JsonRpcResponse[T]) GetResult added in v1.23.8

func (j JsonRpcResponse[T]) GetResult() T

type MinimumLedgerSlotResponse

type MinimumLedgerSlotResponse JsonRpcResponse[uint64]

type Option

type Option func(*RpcClient)

Option is a configuration type for the Client

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint is an Option that allows you configure the rpc endpoint that our client will point to

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

HTTPClient is an Option type that allows you provide your own HTTP client

type RequestAirdropConfig

type RequestAirdropConfig struct {
	Commitment Commitment `json:"commitment,omitempty"`
}

RequestAirdropConfig is a option config for `requestAirdrop`

type RequestAirdropResponse

type RequestAirdropResponse JsonRpcResponse[string]

type ReturnData

type ReturnData struct {
	ProgramId string `json:"programId"`
	Data      any    `json:"data"`
}

type RpcClient

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

func New

func New(opts ...Option) RpcClient

New applies the given options to the rpc client being created. if no options is passed, it defaults to a bare bone http client and solana mainnet

func NewRpcClient

func NewRpcClient(endpoint string) RpcClient

func (*RpcClient) Call

func (c *RpcClient) Call(ctx context.Context, params ...any) ([]byte, error)

Call will return body of response. if http code beyond 200~300, the error also returns.

func (*RpcClient) GetAccountInfo

func (c *RpcClient) GetAccountInfo(ctx context.Context, base58Addr string) (JsonRpcResponse[ValueWithContext[AccountInfo]], error)

GetAccountInfo returns all information associated with the account of provided Pubkey

func (*RpcClient) GetAccountInfoWithConfig

func (c *RpcClient) GetAccountInfoWithConfig(ctx context.Context, base58Addr string, cfg GetAccountInfoConfig) (JsonRpcResponse[ValueWithContext[AccountInfo]], error)

GetAccountInfo returns all information associated with the account of provided Pubkey

func (*RpcClient) GetBalance

func (c *RpcClient) GetBalance(ctx context.Context, base58Addr string) (JsonRpcResponse[ValueWithContext[uint64]], error)

GetBalance returns the SOL balance

func (*RpcClient) GetBalanceWithConfig

func (c *RpcClient) GetBalanceWithConfig(ctx context.Context, base58Addr string, cfg GetBalanceConfig) (JsonRpcResponse[ValueWithContext[uint64]], error)

GetBalanceWithConfig returns the SOL balance

func (*RpcClient) GetBlock

func (c *RpcClient) GetBlock(ctx context.Context, slot uint64) (JsonRpcResponse[GetBlock], error)

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

func (*RpcClient) GetBlockCommitment

func (c *RpcClient) GetBlockCommitment(ctx context.Context, slot uint64) (JsonRpcResponse[GetBlockCommitment], error)

GetBlockCommitment returns commitment for particular block

func (*RpcClient) GetBlockHeight

func (c *RpcClient) GetBlockHeight(ctx context.Context) (JsonRpcResponse[uint64], error)

GetBlockHeight returns the current block height of the node

func (*RpcClient) GetBlockHeightWithConfig

func (c *RpcClient) GetBlockHeightWithConfig(ctx context.Context, cfg GetBlockHeightConfig) (JsonRpcResponse[uint64], error)

GetBlockHeightWithConfig returns the current block height of the node

func (*RpcClient) GetBlockProduction

func (c *RpcClient) GetBlockProduction(ctx context.Context) (JsonRpcResponse[GetBlockProduction], error)

GetBlockProduction returns the current block height of the node

func (*RpcClient) GetBlockProductionWithConfig

func (c *RpcClient) GetBlockProductionWithConfig(ctx context.Context, cfg GetBlockProductionConfig) (JsonRpcResponse[GetBlockProduction], error)

GetBlockProductionWithConfig returns the current block height of the node

func (*RpcClient) GetBlockTime

func (c *RpcClient) GetBlockTime(ctx context.Context, slot uint64) (JsonRpcResponse[*int64], error)

GetBlockTime returns the estimated production time of a block.

func (*RpcClient) GetBlockWithConfig

func (c *RpcClient) GetBlockWithConfig(ctx context.Context, slot uint64, cfg GetBlockConfig) (JsonRpcResponse[GetBlock], error)

GetBlockWithConfig returns identity and transaction information about a confirmed block in the ledger

func (*RpcClient) GetBlocks

func (c *RpcClient) GetBlocks(ctx context.Context, startSlot uint64, endSlot uint64) (JsonRpcResponse[[]uint64], error)

GetBlocks returns a list of confirmed blocks between two slots Max range allowed is 500,000 slot

func (*RpcClient) GetBlocksWithConfig

func (c *RpcClient) GetBlocksWithConfig(ctx context.Context, startSlot uint64, endSlot uint64, cfg GetBlocksConfig) (JsonRpcResponse[[]uint64], error)

GetBlocks returns a list of confirmed blocks between two slots Max range allowed is 500,000 slot

func (*RpcClient) GetBlocksWithLimit

func (c *RpcClient) GetBlocksWithLimit(ctx context.Context, startSlot uint64, limit uint64) (JsonRpcResponse[[]uint64], error)

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

func (*RpcClient) GetBlocksWithLimitWithConfig

func (c *RpcClient) GetBlocksWithLimitWithConfig(ctx context.Context, startSlot uint64, limit uint64, cfg GetBlocksWithLimitConfig) (JsonRpcResponse[[]uint64], error)

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

func (*RpcClient) GetClusterNodes

func (c *RpcClient) GetClusterNodes(ctx context.Context) (JsonRpcResponse[GetClusterNodes], error)

GetClusterNodes returns information about all the nodes participating in the cluster

func (*RpcClient) GetEpochInfo

func (c *RpcClient) GetEpochInfo(ctx context.Context) (JsonRpcResponse[GetEpochInfo], error)

GetEpochInfo returns the SOL balance

func (*RpcClient) GetEpochInfoWithConfig

func (c *RpcClient) GetEpochInfoWithConfig(ctx context.Context, cfg GetEpochInfoConfig) (JsonRpcResponse[GetEpochInfo], error)

GetEpochInfoWithConfig returns the SOL balance

func (*RpcClient) GetEpochSchedule

func (c *RpcClient) GetEpochSchedule(ctx context.Context) (JsonRpcResponse[GetEpochSchedule], error)

GetEpochSchedule returns epoch schedule information from this cluster's genesis config

func (*RpcClient) GetFeeForMessage

func (c *RpcClient) GetFeeForMessage(ctx context.Context, message string) (JsonRpcResponse[ValueWithContext[*uint64]], error)

NEW: This method is only available in solana-core v1.9 or newer. Please use getFees for solana-core v1.8 GetFeeForMessage get the fee the network will charge for a particular Message

func (*RpcClient) GetFeeForMessageWithConfig

func (c *RpcClient) GetFeeForMessageWithConfig(ctx context.Context, message string, cfg GetFeeForMessageConfig) (JsonRpcResponse[ValueWithContext[*uint64]], error)

NEW: This method is only available in solana-core v1.9 or newer. Please use getFees for solana-core v1.8 GetFeeForMessageWithConfig get the fee the network will charge for a particular Message

func (*RpcClient) GetFirstAvailableBlock

func (c *RpcClient) GetFirstAvailableBlock(ctx context.Context) (JsonRpcResponse[uint64], error)

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

func (*RpcClient) GetGenesisHash

func (c *RpcClient) GetGenesisHash(ctx context.Context) (JsonRpcResponse[string], error)

GetGenesisHash returns the genesis hash

func (*RpcClient) GetIdentity

func (c *RpcClient) GetIdentity(ctx context.Context) (JsonRpcResponse[GetIdentity], error)

GetIdentity returns the identity pubkey for the current node

func (*RpcClient) GetInflationGovernor

func (c *RpcClient) GetInflationGovernor(ctx context.Context) (JsonRpcResponse[GetInflationGovernor], error)

GetInflationGovernor returns the current inflation governor

func (*RpcClient) GetInflationGovernorWithConfig

func (c *RpcClient) GetInflationGovernorWithConfig(ctx context.Context, cfg GetInflationGovernorConfig) (JsonRpcResponse[GetInflationGovernor], error)

GetInflationGovernorWithConfig returns the current inflation governor

func (*RpcClient) GetInflationRate

func (c *RpcClient) GetInflationRate(ctx context.Context) (JsonRpcResponse[GetInflationRate], error)

GetInflationRate returns the specific inflation values for the current epoch

func (*RpcClient) GetInflationReward

func (c *RpcClient) GetInflationReward(ctx context.Context, stakeAccountAddrs []string) (JsonRpcResponse[[]*GetInflationReward], error)

GetInflationReward returns the inflation reward for a list of addresses for an epoch

func (*RpcClient) GetInflationRewardWithConfig

func (c *RpcClient) GetInflationRewardWithConfig(ctx context.Context, stakeAccountAddrs []string, cfg GetInflationRewardConfig) (JsonRpcResponse[[]*GetInflationReward], error)

GetInflationRewardWithConfig returns the inflation reward for a list of addresses for an epoch

func (*RpcClient) GetLatestBlockhash

NEW: This method is only available in solana-core v1.9 or newer. Please use getRecentBlockhash for solana-core v1.8 GetLatestBlockhash returns the latest blockhash

func (*RpcClient) GetLatestBlockhashWithConfig

NEW: This method is only available in solana-core v1.9 or newer. Please use getRecentBlockhash for solana-core v1.8 GetLatestBlockhashWithConfig returns the latest blockhash

func (*RpcClient) GetMinimumBalanceForRentExemption

func (c *RpcClient) GetMinimumBalanceForRentExemption(ctx context.Context, dataLen uint64) (JsonRpcResponse[uint64], error)

GetMinimumBalanceForRentExemption returns minimum balance required to make account rent exempt

func (*RpcClient) GetMinimumBalanceForRentExemptionWithConfig

func (c *RpcClient) GetMinimumBalanceForRentExemptionWithConfig(ctx context.Context, dataLen uint64, cfg GetMinimumBalanceForRentExemptionConfig) (JsonRpcResponse[uint64], error)

GetMinimumBalanceForRentExemptionWithConfig returns minimum balance required to make account rent exempt

func (*RpcClient) GetMultipleAccounts

func (c *RpcClient) GetMultipleAccounts(ctx context.Context, base58Addrs []string) (JsonRpcResponse[ValueWithContext[[]AccountInfo]], error)

GetMultipleAccounts returns all information associated with the account of provided Pubkey

func (*RpcClient) GetMultipleAccountsWithConfig

func (c *RpcClient) GetMultipleAccountsWithConfig(ctx context.Context, base58Addrs []string, cfg GetMultipleAccountsConfig) (JsonRpcResponse[ValueWithContext[[]AccountInfo]], error)

GetMultipleAccounts returns all information associated with the account of provided Pubkey

func (*RpcClient) GetProgramAccounts

func (c *RpcClient) GetProgramAccounts(ctx context.Context, programId string) (JsonRpcResponse[GetProgramAccounts], error)

func (*RpcClient) GetProgramAccountsWithConfig

func (c *RpcClient) GetProgramAccountsWithConfig(ctx context.Context, programId string, cfg GetProgramAccountsConfig) (JsonRpcResponse[GetProgramAccounts], error)

func (*RpcClient) GetProgramAccountsWithContext

func (c *RpcClient) GetProgramAccountsWithContext(ctx context.Context, programId string) (JsonRpcResponse[GetProgramAccountsWithContext], error)

func (*RpcClient) GetProgramAccountsWithContextAndConfig

func (c *RpcClient) GetProgramAccountsWithContextAndConfig(ctx context.Context, programId string, cfg GetProgramAccountsConfig) (JsonRpcResponse[GetProgramAccountsWithContext], error)

func (*RpcClient) GetSignatureStatuses

func (c *RpcClient) GetSignatureStatuses(ctx context.Context, signatures []string) (JsonRpcResponse[GetSignatureStatuses], error)

GetSignatureStatuses returns the SOL balance

func (*RpcClient) GetSignatureStatusesWithConfig

func (c *RpcClient) GetSignatureStatusesWithConfig(ctx context.Context, signatures []string, cfg GetSignatureStatusesConfig) (JsonRpcResponse[GetSignatureStatuses], error)

GetSignatureStatusesWithConfig returns the SOL balance

func (*RpcClient) GetSignaturesForAddress

func (c *RpcClient) GetSignaturesForAddress(ctx context.Context, base58Addr string) (JsonRpcResponse[GetSignaturesForAddress], error)

GetSignaturesForAddress returns confirmed signatures for transactions involving an address backwards in time from the provided signature or most recent confirmed block

func (*RpcClient) GetSignaturesForAddressWithConfig

func (c *RpcClient) GetSignaturesForAddressWithConfig(ctx context.Context, base58Addr string, cfg GetSignaturesForAddressConfig) (JsonRpcResponse[GetSignaturesForAddress], error)

GetSignaturesForAddressWithConfig returns confirmed signatures for transactions involving an address backwards in time from the provided signature or most recent confirmed block

func (*RpcClient) GetSlot

func (c *RpcClient) GetSlot(ctx context.Context) (JsonRpcResponse[uint64], error)

GetSlot returns the SOL balance

func (*RpcClient) GetSlotWithConfig

func (c *RpcClient) GetSlotWithConfig(ctx context.Context, cfg GetSlotConfig) (JsonRpcResponse[uint64], error)

GetSlotWithConfig returns the SOL balance

func (*RpcClient) GetTokenAccountBalance

func (c *RpcClient) GetTokenAccountBalance(ctx context.Context, base58Addr string) (JsonRpcResponse[ValueWithContext[TokenAccountBalance]], error)

GetTokenAccountBalance returns the token balance of an SPL Token account

func (*RpcClient) GetTokenAccountBalanceWithConfig

func (c *RpcClient) GetTokenAccountBalanceWithConfig(ctx context.Context, base58Addr string, cfg GetTokenAccountBalanceConfig) (JsonRpcResponse[ValueWithContext[TokenAccountBalance]], error)

GetTokenAccountBalance returns the token balance of an SPL Token account

func (*RpcClient) GetTokenAccountsByOwner

func (c *RpcClient) GetTokenAccountsByOwner(ctx context.Context, base58Addr string, filter GetTokenAccountsByOwnerConfigFilter) (JsonRpcResponse[GetTokenAccountsByOwner], error)

func (*RpcClient) GetTokenSupply

GetTokenSupply returns the token balance of an SPL Token account

func (*RpcClient) GetTokenSupplyWithConfig

GetTokenSupply returns the token balance of an SPL Token account

func (*RpcClient) GetTransaction

func (c *RpcClient) GetTransaction(ctx context.Context, txhash string) (JsonRpcResponse[*GetTransaction], error)

GetTransaction returns transaction details for a confirmed transaction

func (*RpcClient) GetTransactionCount

func (c *RpcClient) GetTransactionCount(ctx context.Context) (JsonRpcResponse[uint64], error)

GetTransactionCount returns the current Transaction count from the ledger

func (*RpcClient) GetTransactionCountWithConfig

func (c *RpcClient) GetTransactionCountWithConfig(ctx context.Context, cfg GetTransactionCountConfig) (JsonRpcResponse[uint64], error)

GetTransactionCountWithConfig returns the current Transaction count from the ledger

func (*RpcClient) GetTransactionWithConfig

func (c *RpcClient) GetTransactionWithConfig(ctx context.Context, txhash string, cfg GetTransactionConfig) (JsonRpcResponse[*GetTransaction], error)

GetTransactionWithConfig returns transaction details for a confirmed transaction

func (*RpcClient) GetVersion

func (c *RpcClient) GetVersion(ctx context.Context) (JsonRpcResponse[GetVersion], error)

GetVersion returns the current solana versions running on the node

func (*RpcClient) GetVoteAccounts

func (c *RpcClient) GetVoteAccounts(ctx context.Context) (JsonRpcResponse[GetVoteAccounts], error)

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

func (*RpcClient) GetVoteAccountsWithConfig

func (c *RpcClient) GetVoteAccountsWithConfig(ctx context.Context, cfg GetVoteAccountsConfig) (JsonRpcResponse[GetVoteAccounts], error)

GetVoteAccountsWithConfig returns the account info and associated stake for all the voting accounts in the current bank.

func (*RpcClient) IsBlockhashValid

func (c *RpcClient) IsBlockhashValid(ctx context.Context, message string) (JsonRpcResponse[ValueWithContext[bool]], error)

IsBlockhashValid get the fee the network will charge for a particular Message

func (*RpcClient) IsBlockhashValidWithConfig

func (c *RpcClient) IsBlockhashValidWithConfig(ctx context.Context, message string, cfg IsBlockhashValidConfig) (JsonRpcResponse[ValueWithContext[bool]], error)

IsBlockhashValidWithConfig get the fee the network will charge for a particular Message

func (*RpcClient) MinimumLedgerSlot

func (c *RpcClient) MinimumLedgerSlot(ctx context.Context) (JsonRpcResponse[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 (*RpcClient) RequestAirdrop

func (c *RpcClient) RequestAirdrop(ctx context.Context, base58Addr string, lamports uint64) (JsonRpcResponse[string], error)

RequestAirdrop requests an airdrop of lamports to a Pubkey

func (*RpcClient) RequestAirdropWithConfig

func (c *RpcClient) RequestAirdropWithConfig(ctx context.Context, base58Addr string, lamports uint64, cfg RequestAirdropConfig) (JsonRpcResponse[string], error)

RequestAirdropWithConfig requests an airdrop of lamports to a Pubkey

func (*RpcClient) SendTransaction

func (c *RpcClient) SendTransaction(ctx context.Context, tx string) (JsonRpcResponse[string], error)

SendTransaction submits a signed transaction to the cluster for processing

func (*RpcClient) SendTransactionWithConfig

func (c *RpcClient) SendTransactionWithConfig(ctx context.Context, tx string, cfg SendTransactionConfig) (JsonRpcResponse[string], error)

SendTransaction submits a signed transaction to the cluster for processing

func (*RpcClient) SimulateTransaction

SimulateTransaction simulate sending a transaction

func (*RpcClient) SimulateTransactionWithConfig

SimulateTransaction simulate sending a transaction

type SendTransactionConfig

type SendTransactionConfig struct {
	SkipPreflight       bool                          `json:"skipPreflight,omitempty"`       // default: false
	PreflightCommitment Commitment                    `json:"preflightCommitment,omitempty"` // default: finalized
	Encoding            SendTransactionConfigEncoding `json:"encoding,omitempty"`            // default: base58
	MaxRetries          uint64                        `json:"maxRetries,omitempty"`
}

type SendTransactionConfigEncoding

type SendTransactionConfigEncoding string
const (
	SendTransactionConfigEncodingBase58 SendTransactionConfigEncoding = "base58"
	SendTransactionConfigEncodingBase64 SendTransactionConfigEncoding = "base64"
)

type SendTransactionResponse

type SendTransactionResponse JsonRpcResponse[string]

type SignatureStatus

type SignatureStatus struct {
	Slot               uint64      `json:"slot"`
	Confirmations      *uint64     `json:"confirmations"`
	ConfirmationStatus *Commitment `json:"confirmationStatus"`
	Err                any         `json:"err"`
}

type SignatureStatuses

type SignatureStatuses []*SignatureStatus

type SignatureWithStatus

type SignatureWithStatus struct {
	Signature string  `json:"signature"`
	Slot      uint64  `json:"slot"`
	BlockTime *int64  `json:"blockTime"`
	Err       any     `json:"err"`
	Memo      *string `json:"memo"`
}

type SimulateTransactionConfig

type SimulateTransactionConfig struct {
	SigVerify              bool                               `json:"sigVerify,omitempty"`              // default: false, conflicts with replace blockhash
	Commitment             Commitment                         `json:"commitment,omitempty"`             // default: finalized
	Encoding               SimulateTransactionEncoding        `json:"encoding,omitempty"`               // default: "base58"
	ReplaceRecentBlockhash bool                               `json:"replaceRecentBlockhash,omitempty"` // default: false, conflicts with sigVerify
	Accounts               *SimulateTransactionConfigAccounts `json:"accounts,omitempty"`
}

type SimulateTransactionConfigAccounts

type SimulateTransactionConfigAccounts struct {
	Encoding AccountEncoding `json:"encoding,omitempty"`
	// An array of accounts to return, as base-58 encoded strings
	Addresses []string `json:"addresses"`
}

type SimulateTransactionEncoding

type SimulateTransactionEncoding string
const (
	SimulateTransactionEncodingBase58 SimulateTransactionEncoding = "base58"
	SimulateTransactionEncodingBase64 SimulateTransactionEncoding = "base64"
)

type SimulateTransactionResponse

type SimulateTransactionResponse JsonRpcResponse[SimulateTransaction]

type SimulateTransactionValue

type SimulateTransactionValue struct {
	Err        any            `json:"err"`
	Logs       []string       `json:"logs,omitempty"`
	Accounts   []*AccountInfo `json:"accounts,omitempty"`
	ReturnData *ReturnData    `json:"returnData,omitempty"`
}

SimulateTransactionValue is a part of SimulateTransactionResponseResult

type TokenAccountBalance

type TokenAccountBalance struct {
	Amount         string `json:"amount"`
	Decimals       uint8  `json:"decimals"`
	UIAmountString string `json:"uiAmountString"`
}

type TransactionEncoding

type TransactionEncoding string
const (
	TransactionEncodingBinary     TransactionEncoding = "binary"
	TransactionEncodingBase64     TransactionEncoding = "base64"
	TransactionEncodingBase58     TransactionEncoding = "base58"
	TransactionEncodingJson       TransactionEncoding = "json"
	TransactionEncodingJsonParsed TransactionEncoding = "jsonParsed"
)

type TransactionLoadedAddresses

type TransactionLoadedAddresses struct {
	Writable []string `json:"writable"`
	Readonly []string `json:"readonly"`
}

type TransactionMeta

type TransactionMeta struct {
	Err                  any                               `json:"err"`
	Fee                  uint64                            `json:"fee"`
	PreBalances          []int64                           `json:"preBalances"`
	PostBalances         []int64                           `json:"postBalances"`
	PreTokenBalances     []TransactionMetaTokenBalance     `json:"preTokenBalances"`
	PostTokenBalances    []TransactionMetaTokenBalance     `json:"postTokenBalances"`
	LogMessages          []string                          `json:"logMessages"`
	InnerInstructions    []TransactionMetaInnerInstruction `json:"innerInstructions"`
	LoadedAddresses      TransactionLoadedAddresses        `json:"loadedAddresses"`
	ReturnData           *ReturnData                       `json:"returnData"`
	ComputeUnitsConsumed *uint64                           `json:"computeUnitsConsumed"`
}

TransactionMeta is a part of GetTransactionResult

type TransactionMetaInnerInstruction

type TransactionMetaInnerInstruction struct {
	Index        uint64 `json:"index"`
	Instructions []any  `json:"instructions"`
}

TransactionMetaInnerInstruction is a part of TransactionMeta

type TransactionMetaReward

type TransactionMetaReward struct {
	Pubkey       string                    `json:"pubkey"`
	Lamports     int64                     `json:"lamports"`
	PostBalances uint64                    `json:"postBalance"`
	RewardType   TransactionMetaRewardType `json:"rewardType"`
	Commission   *uint8                    `json:"commission"`
}

TransactionMetaReward is a part of TransactionMeta

type TransactionMetaRewardType

type TransactionMetaRewardType string
const (
	// currently only "rent", other types may be added in the future
	TransactionMetaRewardTypeRent TransactionMetaRewardType = "rent"
)

type TransactionMetaTokenBalance

type TransactionMetaTokenBalance struct {
	AccountIndex  uint64              `json:"accountIndex"`
	Mint          string              `json:"mint"`
	Owner         string              `json:"owner,omitempty"`
	UITokenAmount TokenAccountBalance `json:"uiTokenAmount"`
}

TransactionMetaTokenBalance is a part of TransactionMeta

type ValueWithContext added in v1.23.8

type ValueWithContext[T any] struct {
	Context Context `json:"context"`
	Value   T       `json:"value"`
}

type VoteAccount

type VoteAccount struct {
	VotePubkey       string      `json:"votePubkey"`
	NodePubkey       string      `json:"nodePubkey"`
	ActivatedStake   uint64      `json:"activatedStake"`
	Commission       uint8       `json:"commission"`
	EpochVoteAccount bool        `json:"epochVoteAccount"`
	LastVote         uint64      `json:"lastVote"`
	EpochCredits     [][3]uint64 `json:"epochCredits"`
	RootSlot         uint64      `json:"rootSlot"`
}

type VoteAccounts

type VoteAccounts []VoteAccount

Jump to

Keyboard shortcuts

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