rpc

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: 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 added in v1.20.0

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

type AccountInfo added in v1.19.0

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 added in v1.20.0

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

type GetAccountInfo added in v1.20.0

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 added in v1.20.0

type GetAccountResponse JsonRpcResponse[GetAccountInfo]

type GetBalance added in v1.20.0

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 added in v1.20.0

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           []Reward              `json:"rewards"`
}

type GetBlockCommitment added in v1.20.0

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 GetBlockProduction added in v1.20.0

type GetBlockProductionConfig added in v1.10.0

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 added in v1.10.0

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

type GetBlockProductionResponse added in v1.10.0

type GetBlockProductionResponse JsonRpcResponse[GetBlockProduction]

type GetBlockProductionResponseResultValue added in v1.10.0

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

type GetBlockResponse

type GetBlockResponse JsonRpcResponse[GetBlock]

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 added in v1.20.0

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

type GetClusterNodes added in v1.20.0

type GetClusterNodes []GetClusterNode

type GetClusterNodesResponse added in v1.10.0

type GetClusterNodesResponse JsonRpcResponse[GetClusterNodes]

type GetEpochInfo added in v1.20.0

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 added in v1.20.0

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 added in v1.10.0

type GetEpochScheduleResponse JsonRpcResponse[GetEpochSchedule]

type GetFeeForMessage added in v1.20.0

type GetFeeForMessage ValueWithContext[*uint64]

type GetFeeForMessageConfig added in v1.13.0

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

GetFeeForMessageConfig is a option config for `GetFeeForMessage`

type GetFeeForMessageResponse added in v1.13.0

type GetFeeForMessageResponse JsonRpcResponse[ValueWithContext[*uint64]]

type GetFirstAvailableBlockResponse

type GetFirstAvailableBlockResponse JsonRpcResponse[uint64]

type GetGenesisHashResponse

type GetGenesisHashResponse JsonRpcResponse[string]

type GetIdentity added in v1.20.0

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

type GetIdentityResponse

type GetIdentityResponse JsonRpcResponse[GetIdentity]

type GetInflationGovernor added in v1.20.0

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 added in v1.10.0

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

GetInflationGovernorConfig is a option config for `getInflationGovernor`

type GetInflationGovernorResponse added in v1.10.0

type GetInflationGovernorResponse JsonRpcResponse[GetInflationGovernor]

type GetInflationRate added in v1.20.0

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 added in v1.20.0

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 added in v1.10.0

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

GetInflationRewardConfig is a option config for `getInflationReward`

type GetInflationRewardResponse added in v1.10.0

type GetInflationRewardResponse JsonRpcResponse[[]*GetInflationReward]

type GetLatestBlockhash added in v1.20.0

type GetLatestBlockhash ValueWithContext[GetLatestBlockhashValue]

type GetLatestBlockhashConfig added in v1.13.0

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

GetLatestBlockhashConfig is a option config for `getLatestBlockhash`

type GetLatestBlockhashResponse added in v1.13.0

type GetLatestBlockhashResponse JsonRpcResponse[GetLatestBlockhash]

type GetLatestBlockhashValue added in v1.13.0

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 added in v1.20.0

type GetMultipleAccounts ValueWithContext[[]AccountInfo]

type GetMultipleAccountsConfig added in v1.13.0

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 added in v1.13.0

type GetMultipleAccountsConfigEncoding string

GetMultipleAccountsConfigEncoding is account's data encode format

type GetMultipleAccountsResponse added in v1.13.0

type GetMultipleAccountsResponse JsonRpcResponse[GetMultipleAccounts]

type GetProgramAccount added in v1.20.0

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 added in v1.20.0

type GetProgramAccountsWithContext ValueWithContext[GetProgramAccounts]

type GetSignatureStatuses added in v1.20.0

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 added in v1.20.0

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 GetTokenAccountBalance added in v1.20.0

type GetTokenAccountBalance ValueWithContext[TokenAccountBalance]

type GetTokenAccountBalanceConfig

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

type GetTokenAccountsByOwner added in v1.20.0

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 GetTokenSupply added in v1.20.0

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 added in v1.20.0

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 added in v1.20.0

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 added in v1.23.0

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

type GetVoteAccountsConfig added in v1.23.0

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 added in v1.23.0

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 added in v1.20.0

type IsBlockhashValid ValueWithContext[bool]

type IsBlockhashValidConfig added in v1.13.0

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

IsBlockhashValidConfig is a option config for `IsBlockhashValid`

type IsBlockhashValidResponse added in v1.13.0

type IsBlockhashValidResponse JsonRpcResponse[IsBlockhashValid]

type JsonRpcError added in v1.20.0

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

func (*JsonRpcError) Error added in v1.22.0

func (e *JsonRpcError) Error() string

type JsonRpcRequest added in v1.20.0

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

type JsonRpcResponse added in v1.20.0

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.24.0

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

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

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

type MinimumLedgerSlotResponse

type MinimumLedgerSlotResponse JsonRpcResponse[uint64]

type Option added in v1.19.0

type Option func(*RpcClient)

Option is a configuration type for the Client

func WithEndpoint added in v1.19.0

func WithEndpoint(endpoint string) Option

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

func WithHTTPClient added in v1.19.0

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 added in v1.23.0

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

type Reward added in v1.24.0

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

type RewardType added in v1.24.0

type RewardType string
const (
	RewardTypeFee     RewardType = "Fee"
	RewardTypeRent    RewardType = "Rent"
	RewardTypeVoting  RewardType = "Voting"
	RewardTypeStaking RewardType = "Staking"
)

type RpcClient

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

func New added in v1.19.0

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 added in v1.10.0

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

GetBlockProduction returns the current block height of the node

func (*RpcClient) GetBlockProductionWithConfig added in v1.10.0

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 added in v1.10.0

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 added in v1.10.0

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

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

func (*RpcClient) GetFeeForMessage added in v1.13.0

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 added in v1.13.0

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 added in v1.10.0

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

GetInflationGovernor returns the current inflation governor

func (*RpcClient) GetInflationGovernorWithConfig added in v1.10.0

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 added in v1.10.0

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 added in v1.10.0

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 added in v1.13.0

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 added in v1.13.0

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 added in v1.13.0

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 added in v1.13.0

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[ValueWithContext[SignatureStatuses]], error)

GetSignatureStatuses returns the SOL balance

func (*RpcClient) GetSignatureStatusesWithConfig

func (c *RpcClient) GetSignatureStatusesWithConfig(ctx context.Context, signatures []string, cfg GetSignatureStatusesConfig) (JsonRpcResponse[ValueWithContext[SignatureStatuses]], 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) 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 added in v1.23.0

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 added in v1.23.0

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 added in v1.13.0

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 added in v1.13.0

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 added in v1.20.0

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

type SignatureStatuses added in v1.20.0

type SignatureStatuses []*SignatureStatus

type SignatureWithStatus added in v1.20.0

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

type SimulateTransaction added in v1.20.0

type SimulateTransaction ValueWithContext[SimulateTransactionValue]

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 added in v1.20.0

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

type SimulateTransactionResponse

type SimulateTransactionResponse JsonRpcResponse[SimulateTransaction]

type SimulateTransactionValue added in v1.20.0

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 added in v1.20.0

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

type TransactionEncoding added in v1.20.0

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

type TransactionLoadedAddresses added in v1.22.0

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"`
	Rewards              []Reward                          `json:"rewards"`
	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 TransactionMetaTokenBalance

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

TransactionMetaTokenBalance is a part of TransactionMeta

type ValueWithContext added in v1.24.0

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

type VoteAccount added in v1.23.0

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 added in v1.23.0

type VoteAccounts []VoteAccount

Jump to

Keyboard shortcuts

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