solana

package module
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 21 Imported by: 0

README

go-solana

Example
package main

import (
	"context"
	"fmt"
	"github.com/cielu/go-solana"
	"github.com/cielu/go-solana/library"
	"github.com/cielu/go-solana/rpc"
	"github.com/cielu/go-solana/solclient"
	"math/big"
)

func main() {
	var (
		ctx = context.Background()
	)
	c, err := solana.Dial(rpc.DevnetRPCEndpoint)
	// err
	if err != nil {
		panic("Failed Dial Solana RPC")
	}
	// account
	account := Base58ToAddress("So11111111111111111111111111111111111111112")
	// get AccountInfo
	res, err := c.GetAccountInfo(ctx, account)
	// has err
	if err != nil {
		fmt.Errorf("GetAccountInfo Failed: %w", err)
		return
	}
	
	// request Airdrop
	signature, err := c.RequestAirdrop(ctx, account, big.NewInt(1000000000))
	// has err
	if err != nil {
		fmt.Errorf("RequestAirdrop Failed: %w", err)
		return
	}
}



Documentation

Index

Constants

View Source
const (
	// HashLength is the expected length of the hash
	HashLength = 32
	// PublicKeyLength is the expected length of the PublicKey
	PublicKeyLength = 32
	// SignatureLength is the expected length of the signature
	SignatureLength = 64
)

Lengths of signatures and PublicKeys in bytes.

Variables

This section is empty.

Functions

func GenerateBase58PrvKey

func GenerateBase58PrvKey(a Account) (string, error)

GenerateBase58PrvKey return base58 private key

func GenerateHexPrvKey

func GenerateHexPrvKey(a Account) (string, error)

GenerateHexPrvKey return hex private key

Types

type Account

type Account struct {
	PublicKey  PublicKey
	PrivateKey ed25519.PrivateKey
}

func AccountFromBase58Key

func AccountFromBase58Key(key string) (Account, error)

AccountFromBase58Key generate an account by base58 private key

func AccountFromBytes

func AccountFromBytes(b []byte) (Account, error)

AccountFromBytes generate an account by bytes

func AccountFromHexKey

func AccountFromHexKey(key string) (Account, error)

AccountFromHexKey generate an account by hex private key

func AccountFromKeygenFile

func AccountFromKeygenFile(file string) (Account, error)

AccountFromKeygenFile generate an account by keygen file

func AccountFromMnemonic

func AccountFromMnemonic(mnemonic string, args ...interface{}) (Account, error)

AccountFromMnemonic generate an account by mnemonic @params [args]: password--> string @params [args]: path --> bool[true] (default: m/44'/501'/0'/0') @params [args]: path --> string (format: m/44'/501'/0'/0')

func AccountFromSeed

func AccountFromSeed(seed []byte) (Account, error)

AccountFromSeed generate an account by seed

func GenerateAccount

func GenerateAccount() (Account, error)

GenerateAccount Random a new account from ed25519

func (Account) Sign

func (a Account) Sign(message []byte) []byte

Sign the message with account

type AccountInfo

type AccountInfo struct {
	// data associated with the account, either as encoded binary data or JSON format {<program>: <state>} - depending on encoding parameter
	Data SolData `json:"data"`
	// base-58 encoded Pubkey of the program this account has been assigned to
	Owner PublicKey `json:"owner"`
	// number of lamports assigned to this account, as an u64
	Lamports *big.Int `json:"lamports"`
	// the epoch at which this account will next owe rent, as u64
	RentEpoch *big.Int `json:"rentEpoch"`
	// boolean indicating if the account contains a program (and is strictly read-only)
	Executable bool `json:"executable"`
	// the data size of the account
	Space uint64 `json:"space,omitempty"`
	//  the data size of the account
	Size uint64 `json:"size,omitempty"`
}

type AccountInfoWithCtx

type AccountInfoWithCtx struct {
	Context     ContextSlot  `json:"context"`
	AccountInfo *AccountInfo `json:"value,omitempty"`
}

type AccountMeta

type AccountMeta struct {
	PublicKey  PublicKey `json:"publickey"`
	IsWritable bool
	IsSigner   bool
}

func Meta

func Meta(pubKey PublicKey) *AccountMeta

Meta intializes a new AccountMeta with the provided pubKey.

func NewAccountMeta

func NewAccountMeta(pubKey PublicKey, WRITE bool, SIGNER bool) *AccountMeta

func (*AccountMeta) Less

func (meta *AccountMeta) Less(act *AccountMeta) bool

func (*AccountMeta) SIGNER

func (meta *AccountMeta) SIGNER() *AccountMeta

SIGNER sets IsSigner to true.

func (*AccountMeta) WRITE

func (meta *AccountMeta) WRITE() *AccountMeta

WRITE sets IsWritable to true.

type AccountMetaSlice

type AccountMetaSlice []*AccountMeta

func (*AccountMetaSlice) Append

func (slice *AccountMetaSlice) Append(account *AccountMeta)

func (AccountMetaSlice) Get

func (slice AccountMetaSlice) Get(index int) *AccountMeta

Get returns the AccountMeta at the desired index. If the index is not present, it returns nil.

func (AccountMetaSlice) GetAccounts

func (slice AccountMetaSlice) GetAccounts() (accounts []*AccountMeta)

func (AccountMetaSlice) GetKeys

func (slice AccountMetaSlice) GetKeys() (keys []PublicKey)

GetKeys returns the pubkeys of all AccountMeta.

func (AccountMetaSlice) GetSigners

func (slice AccountMetaSlice) GetSigners() []*AccountMeta

GetSigners returns the accounts that are signers.

func (AccountMetaSlice) Len

func (slice AccountMetaSlice) Len() int

func (*AccountMetaSlice) SetAccounts

func (slice *AccountMetaSlice) SetAccounts(accounts []*AccountMeta) error

type AccountNotifies

type AccountNotifies AccountInfoWithCtx

type AccountWithLamport

type AccountWithLamport struct {
	// base-58 encoded address of the account
	Address PublicKey `json:"address"`
	// number of lamports in the account, as a u64
	Lamports *big.Int `json:"lamports"`
}

type AccountsGettable

type AccountsGettable interface {
	GetAccounts() (accounts []*AccountMeta)
}

type AccountsInfoWithCtx

type AccountsInfoWithCtx struct {
	Context  ContextSlot    `json:"context"`
	Accounts []*AccountInfo `json:"value,omitempty"`
}

type AccountsSettable

type AccountsSettable interface {
	SetAccounts(accounts []*AccountMeta) error
}

type BalanceWithCtx

type BalanceWithCtx struct {
	Context ContextSlot `json:"context"`
	Balance *big.Int    `json:"value"`
}

type Base58Data added in v0.3.4

type Base58Data []byte

func (Base58Data) Base58 added in v0.3.4

func (t Base58Data) Base58() string

func (Base58Data) Hex added in v0.3.4

func (t Base58Data) Hex() string

func (Base58Data) MarshalJSON added in v0.3.4

func (t Base58Data) MarshalJSON() ([]byte, error)

func (Base58Data) String added in v0.3.4

func (t Base58Data) String() string

func (*Base58Data) UnmarshalJSON added in v0.3.4

func (t *Base58Data) UnmarshalJSON(data []byte) (err error)

type BlockCommitment

type BlockCommitment struct {
	// nil if Unknown block, or array of u64 integers
	// logging the amount of cluster stake in lamports
	// that has voted on the block at each depth from 0 to `MAX_LOCKOUT_HISTORY` + 1
	Commitment []uint64 `json:"commitment"`

	// Total active stake, in lamports, of the current epoch.
	TotalStake uint64 `json:"totalStake"`
}

type BlockInfo

type BlockInfo struct {
	Err               json.RawMessage   `json:"err"`
	BlockHeight       uint64            `json:"blockHeight"`
	BlockTime         int64             `json:"blockTime"`
	ParentSlot        uint64            `json:"parentSlot"`
	BlockHash         Hash              `json:"blockHash"`
	PreviousBlockhash Hash              `json:"previousBlockhash"`
	Rewards           []BlockReward     `json:"rewards"`
	Transactions      []TransactionInfo `json:"transactions"`
}

type BlockNotifies

type BlockNotifies struct {
	Context   ContextSlot `json:"context"`
	BlockInfo BlockInfo   `json:"value"`
}

type BlockProduction

type BlockProduction struct {
	ByIdentity map[string][2]uint `json:"byIdentity"`
	Range      SlotRange          `json:"range"`
}

type BlockProductionWithCtx

type BlockProductionWithCtx struct {
	Context         ContextSlot     `json:"context"`
	BlockProduction BlockProduction `json:"value"`
}

type BlockReward

type BlockReward struct {
	Commission  *uint8    `json:"commission"`
	Lamports    *big.Int  `json:"lamports"`
	PostBalance uint64    `json:"postBalance"`
	RewardType  string    `json:"rewardType"`
	Pubkey      PublicKey `json:"pubkey"`
}

type Client

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

Client defines typed wrappers for the solana 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) Close

func (sc *Client) Close()

Close closes the underlying RPC connection.

func (*Client) GetAccountInfo

func (sc *Client) GetAccountInfo(ctx context.Context, account PublicKey, cfg ...RpcAccountInfoCfg) (res 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 PublicKey, cfg ...RpcCommitmentWithMinSlotCfg) (balance 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 ...RpcGetBlockContextCfg) (blockInfo 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 BlockCommitment, err error)

GetBlockCommitment Returns commitment for particular block

func (*Client) GetBlockHeight

func (sc *Client) GetBlockHeight(ctx context.Context, cfg ...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 ...RpcGetBlockProduction) (res 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 ...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 []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 ...RpcCommitmentWithMinSlotCfg) (res EpochInformation, err error)

GetEpochInfo Returns information about the current epoch

func (*Client) GetEpochSchedule

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

GetEpochSchedule Returns information about the current epoch

func (*Client) GetFeeForMessage

func (sc *Client) GetFeeForMessage(ctx context.Context, msg string, cfg ...RpcCommitmentWithMinSlotCfg) (res 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 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 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 Identity, err error)

GetIdentity Returns the identity pubkey for the current node

func (*Client) GetInflationGovernor

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

GetInflationGovernor Returns the current inflation governor

func (*Client) GetInflationRate

func (sc *Client) GetInflationRate(ctx context.Context) (res 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 []InflationReward, err error)

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

func (*Client) GetLargestAccounts

func (sc *Client) GetLargestAccounts(ctx context.Context, cfg ...RpcCommitmentWithFilter) (res 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 ...RpcCommitmentWithMinSlotCfg) (res 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 []PublicKey, cfg ...RpcAccountInfoCfg) (res AccountsInfoWithCtx, err error)

GetMultipleAccounts Returns the account information for a list of Pubkeys.

func (*Client) GetProgramAccounts

func (sc *Client) GetProgramAccounts(ctx context.Context, program PublicKey, cfg ...RpcCombinedCfg) (res []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 []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 []RpcPrioritizationFee, err error)

GetRecentPrioritizationFees Returns a list of prioritization fees from recent blocks.

func (*Client) GetSignatureStatuses

func (sc *Client) GetSignatureStatuses(ctx context.Context, signatures []Signature, cfg ...RpcSearchTxHistoryCfg) (res 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 added in v0.3.2

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

GetSignaturesForAddress Returns signatures for confirmed transactions that include the given PublicKey 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 ...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 ...RpcCommitmentWithMinSlotCfg) (res PublicKey, err error)

GetSlotLeader Returns the current slot leader

func (*Client) GetSlotLeaders

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

GetSlotLeaders Returns the slot leaders for a given slot range

func (*Client) GetStakeActivation

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

GetStakeActivation Returns epoch activation information for a stake account

func (*Client) GetStakeMinimumDelegation

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

GetStakeMinimumDelegation Returns the stake minimum delegation, in lamports.

func (*Client) GetSupply

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

GetSupply Returns information about the current supply.

func (*Client) GetTokenAccountBalance

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

GetTokenAccountBalance Returns the token balance of an SPL Token account.

func (*Client) GetTokenAccountsByDelegate

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

GetTokenAccountsByDelegate Returns all SPL Token accounts by approved Delegate.

func (*Client) GetTokenAccountsByOwner

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

GetTokenAccountsByOwner Returns all SPL Token accounts by token owner.

func (*Client) GetTokenLargestAccounts

func (sc *Client) GetTokenLargestAccounts(ctx context.Context, splToken PublicKey, cfg ...RpcCommitmentCfg) (res 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 PublicKey, cfg ...RpcCommitmentCfg) (res TokenAccountWithCtx, err error)

GetTokenSupply Returns the total supply of an SPL Token type.

func (*Client) GetTransaction

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

GetTransaction Returns transaction details for a confirmed transaction

func (*Client) GetTransactionCount

func (sc *Client) GetTransactionCount(ctx context.Context, cfg ...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 SolVersion, err error)

GetVersion Returns the current Solana version running on the node

func (*Client) GetVoteAccounts

func (sc *Client) GetVoteAccounts(ctx context.Context, cfg ...RpcVoteAccountCfg) (res 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 Hash, cfg ...RpcCommitmentWithMinSlotCfg) (res bool, err error)

IsBlockHashValid Returns whether a blockHash is still valid or not

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) RequestAirdrop

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

RequestAirdrop Requests an airdrop of lamports to a Pubkey

func (*Client) SendTransaction

func (sc *Client) SendTransaction(ctx context.Context, signedTx Base58Data, cfg ...RpcSendTxCfg) (res 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

func (sc *Client) SetDebug(isDebug bool)

SetDebug set solClient debug

func (*Client) SimulateTransaction

func (sc *Client) SimulateTransaction(ctx context.Context, signedTx Base58Data) (res SimulateResult, err error)

SimulateTransaction Simulate sending a transaction

type ClusterInformation

type ClusterInformation struct {
	// Node public key, as base-58 encoded string
	PubKey PublicKey `json:"pubKey"`
	// Gossip network address for the node
	Gossip string `json:"gossip,omitempty"`
	// TPU network address for the node
	Tpu string `json:"tpu,omitempty"`
	// JSON RPC network address for the node, or null if the JSON RPC service is not enabled
	Rpc string `json:"rpc,omitempty"`
	// The software version of the node, or null if the version information is not available
	Version string `json:"version,omitempty"`
	// The unique identifier of the node's feature set
	FeatureSet *uint32 `json:"featureSet,omitempty"`
	// The shred version the node has been configured to use
	ShredVersion *uint16 `json:"shredVersion,omitempty"`
}

type CompiledInstruction

type CompiledInstruction struct {
	// StackHeight if empty
	StackHeight *uint16 `json:"stackHeight"`
	// Index into the message.accountKeys array indicating the program account that executes this instruction.
	// NOTE: it is actually a uint8, but using a uint16 because uint8 is treated as a byte everywhere,
	// and that can be an issue.
	ProgramIDIndex uint16 `json:"programIdIndex"`
	// List of ordered indices into the message.accountKeys array indicating which accounts to pass to the program.
	// NOTE: it is actually a []uint8, but using a uint16 because []uint8 is treated as a []byte everywhere,
	// and that can be an issue.
	Accounts []uint16 `json:"accounts"`
	// The program input data encoded in a base-58 string.
	Data Base58Data `json:"data"`
}

type ContextSlot

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

type DataSlice

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

DataSlice Request a slice of the data range.

type EncodingEnum added in v0.3.4

type EncodingEnum string
const (
	EncodingBase58     EncodingEnum = "base58"
	EncodingBase64     EncodingEnum = "base64"
	EncodingBase64Zstd EncodingEnum = "base64+zstd"
	EncodingJson       EncodingEnum = "json"
	EncodingJsonParsed EncodingEnum = "jsonParsed"
)

base58 base64 base64+zstd jsonParsed

type EnumCirculateFilter

type EnumCirculateFilter string
const (
	FilterCirculating    EnumCirculateFilter = "circulating"
	FilterNonCirculating EnumCirculateFilter = "nonCirculating"
)

filter results by account type

type EnumRpcCommitment

type EnumRpcCommitment string
const (
	// RpcCommitmentFinalized the node will query the most recent block confirmed
	// by supermajority of the cluster as having reached maximum lockout,
	// meaning the cluster has recognized this block as finalized
	RpcCommitmentFinalized EnumRpcCommitment = "finalized"

	// RpcCommitmentConfirmed the node will query the most recent block
	// that has been voted on by supermajority of the cluster.
	RpcCommitmentConfirmed EnumRpcCommitment = "confirmed"

	// RpcCommitmentProcessed the node will query its most recent block.
	// Note that the block may still be skipped by the cluster.
	RpcCommitmentProcessed EnumRpcCommitment = "processed"
)

Rpc commitment context config

type EnumTxDetailLevel

type EnumTxDetailLevel string
const (
	TxDetailLevelNone       EnumTxDetailLevel = "none"
	TxDetailLevelFull       EnumTxDetailLevel = "full"
	TxDetailLevelAccounts   EnumTxDetailLevel = "accounts"
	TxDetailLevelSignatures EnumTxDetailLevel = "signatures"
)

level of transaction detail to return

type EpochInformation

type EpochInformation struct {
	// the current slot
	AbsoluteSlot uint64 `json:"absoluteSlot"`
	// the current block height
	BlockHeight uint64 `json:"blockHeight"`
	// the current epoch
	Epoch uint64 `json:"epoch"`
	// the current slot relative to the start of the current epoch
	SlotIndex uint64 `json:"slotIndex"`
	// the number of slots in this epoch
	SlotsInEpoch uint64 `json:"slotsInEpoch"`
	// total number of transactions processed without error since genesis
	TransactionCount *uint64 `json:"transactionCount"`
}

type EpochSchedule

type EpochSchedule struct {
	// the maximum number of slots in each epoch
	SlotsPerEpoch uint64 `json:"slotsPerEpoch"`
	// the number of slots before beginning of an epoch to calculate a leader schedule for that epoch
	LeaderScheduleSlotOffset uint64 `json:"leaderScheduleSlotOffset"`
	// whether epochs start short and grow
	Warmup bool `json:"warmup"`
	// first normal-length epoch, log2(slotsPerEpoch) - log2(MINIMUM_SLOTS_PER_EPOCH)
	FirstNormalEpoch uint64 `json:"firstNormalEpoch"`
	// MINIMUM_SLOTS_PER_EPOCH * (2.pow(firstNormalEpoch) - 1)
	FirstNormalSlot uint64 `json:"firstNormalSlot"`
}

type Hash

type Hash [HashLength]byte

Hash The Hash

func Base58ToHash

func Base58ToHash(b string) Hash

Base58ToHash returns Hash with byte values of b.

func BytesToHash

func BytesToHash(b []byte) (h Hash)

BytesToHash returns Hash with value b.

func StrToHash

func StrToHash(b string) Hash

StrToHash returns Hash with byte values of b. Notice: only support base58/base64 str

func (Hash) Base58

func (h Hash) Base58() string

Base58 return base58 account

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes return Hash bytes

func (Hash) Cmp

func (h Hash) Cmp(other Hash) int

Cmp compares two Hashes.

func (Hash) ImplementsGraphQLType

func (h Hash) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (Hash) MarshalJSON added in v0.3.4

func (h Hash) MarshalJSON() ([]byte, error)

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

MarshalText returns base58 str hash

func (*Hash) Scan

func (h *Hash) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes sets the Hash to the value of b.

func (Hash) String

func (h Hash) String() string

String return base58 account

func (*Hash) UnmarshalGraphQL

func (h *Hash) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query data.

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in base58 syntax.

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error

UnmarshalText parses a hash in base58 syntax.

func (Hash) Value

func (h Hash) Value() (driver.Value, error)

Value implements valuer for database/sql.

type HighestSnapshotSlot

type HighestSnapshotSlot struct {
	Full        uint64  `json:"full"`
	Incremental *uint64 `json:"incremental,omitempty"`
}

type Identity

type Identity struct {
	Identity PublicKey `json:"identity"`
}

type InflationGovernor

type InflationGovernor struct {
	// the initial inflation percentage from time 0
	Initial float64 `json:"initial"`
	// terminal inflation percentage
	Terminal float64 `json:"terminal"`
	// rate per year at which inflation is lowered. (Rate reduction is derived using the target slot time in genesis config)
	Taper float64 `json:"taper"`
	// percentage of total inflation allocated to the foundation
	Foundation float64 `json:"foundation"`
	// duration of foundation pool inflation in years
	FoundationTerm float64 `json:"foundationTerm"`
}

type InflationRate

type InflationRate struct {
	// total inflation
	Total float64 `json:"total"`
	// inflation allocated to validators
	Validator float64 `json:"validator"`
	// inflation allocated to the foundation
	Foundation float64 `json:"foundation"`
	// epoch for which these values are valid
	Epoch uint64 `json:"epoch"`
}

type InflationReward

type InflationReward struct {
	// epoch for which reward occured
	Epoch uint64 `json:"epoch"`
	// the slot in which the rewards are effective
	EffectiveSlot uint64 `json:"effectiveSlot"`
	// reward amount in lamports
	Amount uint64 `json:"amount"`
	// post balance of the account in lamports
	PostBalance uint64 `json:"postBalance"`
	// vote account commission when the reward was credited
	Commission *uint8 `json:"commission,omitempty"`
}

type InnerInstruction

type InnerInstruction struct {
	// Index of the transaction instruction from which the inner instruction(s) originated
	Index uint16 `json:"index"`

	// Ordered list of inner program instructions that were invoked during a single transaction instruction.
	Instructions []CompiledInstruction `json:"instructions"`
}

type Instruction

type Instruction interface {
	ProgramID() PublicKey     // the programID the instruction acts on
	Accounts() []*AccountMeta // returns the list of accounts the instructions requires
	Data() ([]byte, error)    // the binary encoded instructions
}

type LastBlock

type LastBlock struct {
	// a Hash as base-58 encoded string
	Blockhash Hash `json:"blockhash"`
	//  last block height at which the blockhash will be valid
	LastValidBlockHeight uint64 `json:"lastValidBlockHeight"`
}

type LastBlockWithCtx

type LastBlockWithCtx struct {
	Context   ContextSlot `json:"context"`
	LastBlock LastBlock   `json:"value"`
}

type LoadedAddresses

type LoadedAddresses struct {
	ReadOnly []PublicKey `json:"readonly,omitempty"`
	Writable []PublicKey `json:"writable,omitempty"`
}

type LogsNotifies

type LogsNotifies struct {
	Context ContextSlot `json:"context"`
	Value   LogsValue   `json:"value"`
}

type LogsValue

type LogsValue struct {
	Signature Signature       `json:"signature"`
	Err       json.RawMessage `json:"err"`
	Logs      []string        `json:"logs"`
}

type MentionsAccountProgramCfg

type MentionsAccountProgramCfg struct {
	MentionsAccountOrProgram PublicKey `json:"MentionsAccountOrProgram,omitempty"`
}

type MentionsCfg

type MentionsCfg struct {
	Mentions []PublicKey `json:"mentions,omitempty"`
}

type Message

type Message struct {

	// List of base-58 encoded public keys used by the transaction,
	// including by the instructions and for signatures.
	// The first `message.header.numRequiredSignatures` public keys must sign the transaction.
	AccountKeys []PublicKey `json:"accountKeys"`
	// Details the account types and signatures required by the transaction.
	Header MessageHeader `json:"header"`
	// A base-58 encoded hash of a recent block in the ledger used to
	// prevent transaction duplication and to give transactions lifetimes.
	RecentBlockhash Hash `json:"recentBlockhash"`
	// List of program instructions that will be executed in sequence
	// and committed in one atomic transaction if all succeed.
	Instructions []CompiledInstruction `json:"instructions"`
	// List of address table lookups used to load additional accounts for this transaction.
	AddressTableLookups MessageAddressTableLookupSlice `json:"addressTableLookups"`
	// contains filtered or unexported fields
}

func (*Message) AddAddressTableLookup added in v0.3.4

func (m *Message) AddAddressTableLookup(lookup MessageAddressTableLookup) *Message

AddAddressTableLookup adds a new lookup to the message.

func (Message) GetAddressTableLookupAccounts added in v0.3.6

func (m Message) GetAddressTableLookupAccounts() ([]PublicKey, error)

GetAddressTableLookupAccounts associates the lookups with the accounts in the actual address tables, and returns the accounts. NOTE: you need to call `SetAddressTables` before calling this method, so that the lookups can be associated with the accounts in the address tables.

func (*Message) GetAddressTables added in v0.3.4

func (m *Message) GetAddressTables() map[PublicKey][]PublicKey

GetAddressTables returns the actual address tables used by this message. NOTE: you must have called `SetAddressTable` before being able to use this method.

func (Message) GetAllKeys added in v0.3.6

func (m Message) GetAllKeys() (keys []PublicKey, err error)

GetAllKeys returns ALL the message's account keys (including the keys from resolved address lookup tables).

func (Message) GetProgram

func (m Message) GetProgram(idIndex uint16) PublicKey

GetProgram current program address

func (*Message) GetVersion added in v0.3.4

func (m *Message) GetVersion() MessageVersion

GetVersion returns the message version.

func (*Message) IsSigner

func (m *Message) IsSigner(account PublicKey) bool

func (Message) IsVersioned added in v0.3.6

func (m Message) IsVersioned() bool

func (*Message) IsWritable

func (m *Message) IsWritable(account PublicKey) bool

func (*Message) MarshalBinary

func (m *Message) MarshalBinary() ([]byte, error)

func (*Message) MarshalLegacy added in v0.3.4

func (m *Message) MarshalLegacy() ([]byte, error)

func (*Message) MarshalV0 added in v0.3.4

func (m *Message) MarshalV0() ([]byte, error)

func (*Message) SetAddressTableLookups added in v0.3.4

func (m *Message) SetAddressTableLookups(lookups []MessageAddressTableLookup) *Message

SetAddressTableLookups (re)sets the lookups used by this message.

func (*Message) SetAddressTables added in v0.3.4

func (m *Message) SetAddressTables(tables map[PublicKey][]PublicKey) error

SetAddressTables sets the actual address tables used by this message. Use `mx.GetAddressTableLookups().GetTableIDs()` to get the list of all address table IDs. NOTE: you can call this once.

func (*Message) Signers

func (m *Message) Signers() []PublicKey

Signers returns the pubkeys of all accounts that are signers.

func (*Message) UnmarshalBase64

func (m *Message) UnmarshalBase64(b64 string) error

func (*Message) UnmarshalLegacy

func (m *Message) UnmarshalLegacy(decoder *encodbin.Decoder) (err error)

func (*Message) UnmarshalV0

func (m *Message) UnmarshalV0(decoder *encodbin.Decoder) (err error)

func (*Message) UnmarshalWithDecoder

func (m *Message) UnmarshalWithDecoder(decoder *encodbin.Decoder) (err error)

func (*Message) Writable

func (m *Message) Writable() (out []PublicKey)

Writable returns the pubkeys of all accounts that are writable.

type MessageAddressTableLookup

type MessageAddressTableLookup struct {
	AccountKey      PublicKey  `json:"accountKey"` // The account key of the address table.
	WritableIndexes Uint8Slice `json:"writableIndexes"`
	ReadonlyIndexes Uint8Slice `json:"readonlyIndexes"`
}

type MessageAddressTableLookupSlice

type MessageAddressTableLookupSlice []MessageAddressTableLookup

func (MessageAddressTableLookupSlice) GetTableIDs

func (lookups MessageAddressTableLookupSlice) GetTableIDs() []PublicKey

GetTableIDs returns the list of all address table IDs.

func (MessageAddressTableLookupSlice) NumLookups

func (lookups MessageAddressTableLookupSlice) NumLookups() int

NumLookups returns the number of accounts in all the MessageAddressTableLookupSlice

func (MessageAddressTableLookupSlice) NumWritableLookups added in v0.3.4

func (lookups MessageAddressTableLookupSlice) NumWritableLookups() int

NumWritableLookups returns the number of writable accounts across all the lookups (all the address tables).

type MessageHeader

type MessageHeader struct {
	// The total number of signatures required to make the transaction valid.
	// The signatures must match the first `numRequiredSignatures` of `message.account_keys`.
	NumRequiredSignatures uint8 `json:"numRequiredSignatures"`

	// The last numReadonlySignedAccounts of the signed keys are read-only accounts.
	// Programs may process multiple transactions that load read-only accounts within
	// a single PoH entry, but are not permitted to credit or debit lamports or modify
	// account data.
	// Transactions targeting the same read-write account are evaluated sequentially.
	NumReadonlySignedAccounts uint8 `json:"numReadonlySignedAccounts"`

	// The last `numReadonlyUnsignedAccounts` of the unsigned keys are read-only accounts.
	NumReadonlyUnsignedAccounts uint8 `json:"numReadonlyUnsignedAccounts"`
}

type MessageVersion

type MessageVersion int
const (
	MessageVersionLegacy MessageVersion = 0 // default
	MessageVersionV0     MessageVersion = 1 // v0
)

type ProgramAccount

type ProgramAccount struct {
	Account AccountInfo `json:"account"`
	PubKey  PublicKey   `json:"pubKey"`
}

ProgramAccount program account

type ProgramNotifies

type ProgramNotifies struct {
	Context ContextSlot  `json:"context"`
	Value   TokenAccount `json:"value"`
}

type PublicKey

type PublicKey [PublicKeyLength]byte

PublicKey The PublicKey

func Base58ToPublicKey

func Base58ToPublicKey(b string) PublicKey

Base58ToPublicKey returns PublicKey with byte values of b.

func BytesToPublicKey

func BytesToPublicKey(b []byte) (a PublicKey)

BytesToPublicKey returns PublicKey with value b.

func StrToPublicKey

func StrToPublicKey(b string) PublicKey

StrToPublicKey returns PublicKey with byte values of b. Notice: only support base58/base64 str

func (PublicKey) Base58

func (p PublicKey) Base58() string

Base58 return base58 account

func (PublicKey) Bytes

func (p PublicKey) Bytes() []byte

Bytes return PublicKey bytes

func (PublicKey) Cmp

func (p PublicKey) Cmp(other PublicKey) int

Cmp compares two PublicKeyes.

func (PublicKey) Equals

func (p PublicKey) Equals(b PublicKey) bool

Equals compares PublicKey a eq b

func (PublicKey) ImplementsGraphQLType

func (p PublicKey) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (PublicKey) IsEmpty

func (p PublicKey) IsEmpty() bool

IsEmpty PublicKey is empty

func (PublicKey) MarshalJSON added in v0.3.4

func (p PublicKey) MarshalJSON() ([]byte, error)

func (PublicKey) MarshalText

func (p PublicKey) MarshalText() ([]byte, error)

MarshalText returns base58 str account

func (*PublicKey) Scan

func (p *PublicKey) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*PublicKey) SetBytes

func (p *PublicKey) SetBytes(b []byte)

SetBytes sets the PublicKey to the value of b.

func (PublicKey) String

func (p PublicKey) String() string

String return base58 account

func (*PublicKey) UnmarshalGraphQL

func (p *PublicKey) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query data.

func (*PublicKey) UnmarshalJSON

func (p *PublicKey) UnmarshalJSON(input []byte) error

UnmarshalJSON parses an account in base58 syntax.

func (*PublicKey) UnmarshalText

func (p *PublicKey) UnmarshalText(input []byte) error

UnmarshalText parses an account in base58 syntax.

func (PublicKey) Value

func (p PublicKey) Value() (driver.Value, error)

Value implements valuer for database/sql.

type RawTransaction

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

func NewRawTransaction

func NewRawTransaction(blockHash Hash, payer string, inst []Instruction, signers []string) *RawTransaction

type RpcAccountInfoCfg

type RpcAccountInfoCfg struct {
	Encoding       EncodingEnum      `json:"encoding,omitempty"`
	Commitment     EnumRpcCommitment `json:"commitment,omitempty"`
	MinContextSlot *uint64           `json:"minContextSlot,omitempty"`
	DataSlice      *DataSlice        `json:"dataSlice,omitempty"`
}

RpcAccountInfoCfg Get multiple data

type RpcCombinedCfg

type RpcCombinedCfg struct {
	WithContext    bool                     `json:"withContext,omitempty"`
	Encoding       EncodingEnum             `json:"encoding,omitempty"`
	Commitment     EnumRpcCommitment        `json:"commitment,omitempty"`
	MinContextSlot *uint64                  `json:"minContextSlot,omitempty"`
	DataSlice      *DataSlice               `json:"dataSlice,omitempty"`
	Filter         []map[string]interface{} `json:"filter,omitempty"`
}

type RpcCommitmentCfg

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

RpcCommitmentCfg rpc config of commitment

type RpcCommitmentWithEncodingCfg

type RpcCommitmentWithEncodingCfg struct {
	Commitment EnumRpcCommitment `json:"commitment,omitempty"`
	Encoding   EncodingEnum      `json:"encoding,omitempty"`
}

RpcCommitmentWithEncodingCfg rpc config of commitment

type RpcCommitmentWithFilter

type RpcCommitmentWithFilter struct {
	Commitment EnumRpcCommitment   `json:"commitment,omitempty"`
	Filter     EnumCirculateFilter `json:"filter,omitempty"`
}

RpcCommitmentWithFilter commitment with filter

type RpcCommitmentWithIdentity

type RpcCommitmentWithIdentity struct {
	Commitment EnumRpcCommitment `json:"commitment,omitempty"`
	Identity   *PublicKey        `json:"identity,omitempty"`
}

type RpcCommitmentWithMinSlotCfg

type RpcCommitmentWithMinSlotCfg struct {
	Commitment     EnumRpcCommitment `json:"commitment,omitempty"`
	MinContextSlot *uint64           `json:"minContextSlot,omitempty"`
}

RpcCommitmentWithMinSlotCfg commitment & min slot

type RpcGetBlockContextCfg

type RpcGetBlockContextCfg struct {
	Commitment            EnumRpcCommitment `json:"commitment,omitempty"`
	Encoding              EncodingEnum      `json:"encoding,omitempty"`
	TransactionDetails    EnumTxDetailLevel `json:"transactionDetails,omitempty"`
	MaxSupportedTxVersion uint8             `json:"maxSupportedTransactionVersion"`
	Rewards               *bool             `json:"rewards,omitempty"`
}

RpcGetBlockContextCfg commitment & min slot

type RpcGetBlockProduction

type RpcGetBlockProduction struct {
	Commitment EnumRpcCommitment `json:"commitment,omitempty"`
	Identity   *PublicKey        `json:"identity,omitempty"`
	Range      SlotRange         `json:"range,omitempty"`
}

RpcGetBlockProduction getBlock production

type RpcGetTransactionCfg

type RpcGetTransactionCfg struct {
	Commitment EnumRpcCommitment `json:"commitment,omitempty"`
	Encoding   EncodingEnum      `json:"encoding,omitempty"`

	// MaxSupportedTransactionVersion Set the max transaction version to return in responses.
	// If the requested transaction is a higher version, an error will be returned.
	// If this parameter is omitted, only legacy transactions will be returned, and any versioned transaction will prompt the error.
	MaxSupportedTxVersion uint8 `json:"maxSupportedTransactionVersion,omitempty"`
}

RpcGetTransactionCfg commitment & min slot

type RpcMintWithProgramID

type RpcMintWithProgramID struct {
	Mint      *PublicKey `json:"mint,omitempty"`
	ProgramId *PublicKey `json:"programId,omitempty"`
}

type RpcPerfSample

type RpcPerfSample struct {
	// Slot in which sample was taken at
	Slot uint64 `json:"slot"`
	// Number of transactions processed during the sample period
	NumTransactions uint64 `json:"numTransactions"`
	// Number of slots completed during the sample period
	NumSlots uint64 `json:"numSlots"`
	// Number of seconds in a sample window
	SamplePeriodSecs uint16 `json:"samplePeriodSecs"`
	// Number of non-vote transactions processed during the sample period.
	NumNonVoteTransaction uint64 `json:"numNonVoteTransaction"`
}

type RpcPrioritizationFee

type RpcPrioritizationFee struct {
	// slot in which the fee was observed
	Slot uint64 `json:"slot"`
	// the per-compute-unit fee paid by at least one successfully landed transaction, specified in increments of micro-lamports (0.000001 lamports)
	PrioritizationFee uint64 `json:"prioritizationFee"`
}

type RpcSearchTxHistoryCfg

type RpcSearchTxHistoryCfg struct {
	// if true - a Solana node will search its ledger cache for any signatures not found in the recent status cache
	SearchTxHistory bool `json:"searchTransactionHistory,omitempty"`
}

type RpcSendTxCfg

type RpcSendTxCfg struct {
	// Encoding used for the transaction data.
	// Default: base58
	// Values: base58 (slow, DEPRECATED), or base64.
	Encoding EncodingEnum `json:"encoding,omitempty"`
	// Default: false
	// when true, skip the preflight transaction checks
	SkipPreflight bool `json:"skipPreflight,omitempty"`
	// Default: finalized
	// Commitment level to use for preflight.
	PreflightCommitment string `json:"preflightCommitment,omitempty"`
	// Maximum number of times for the RPC node to retry sending the transaction to the leader.
	// If this parameter not provided, the RPC node will retry the transaction until it is finalized or until the blockhash expires.
	MaxRetries *uint64 `json:"maxRetries,omitempty"`
	// set the minimum slot at which to perform preflight transaction checks
	MinContextSlot *uint64 `json:"minContextSlot,omitempty"`
}

RpcSendTxCfg struct

type RpcSignaturesForAddressCfg

type RpcSignaturesForAddressCfg struct {
	Commitment     EnumRpcCommitment `json:"commitment,omitempty"`
	MinContextSlot *uint64           `json:"minContextSlot,omitempty"`
	// Limit: maximum transaction signatures to return (between 1 and 1,000).
	Limit *uint `json:"limit,omitempty"`
	// start searching backwards from this transaction signature.
	// If not provided the search starts from the top of the highest max confirmed block.
	Before string `json:"before,omitempty"`
	// search until this transaction signature, if found before limit reached
	Util string `json:"util,omitempty"`
}

type RpcSupplyCfg

type RpcSupplyCfg struct {
	Commitment EnumRpcCommitment `json:"commitment,omitempty"`
	// exclude non circulating accounts list from response
	ExcludeNonCirculatingAccountsList *bool `json:"excludeNonCirculatingAccountsList,omitempty"`
}

type RpcVoteAccountCfg

type RpcVoteAccountCfg struct {
	// commitment
	Commitment EnumRpcCommitment `json:"commitment,omitempty"`
	// Only return results for this validator vote address (base-58 encoded)
	VotePubkey *PublicKey `json:"votePubkey,omitempty"` //  optional
	// Do not filter out delinquent validators with no stake
	KeepUnstakedDelinquents *bool `json:"keepUnstakedDelinquents,omitempty"` //  optional
	// Specify the number of slots behind the tip that a validator must fall to be considered delinquent. NOTE: For the sake of consistency between ecosystem products, it is not recommended that this argument be specified.
	DelinquentSlotDistance *uint64 `json:"delinquentSlotDistance,omitempty"` // optional
}

type RpcVoteAccounts

type RpcVoteAccounts struct {
	Current    []VoteAccount `json:"current"`
	Delinquent []VoteAccount `json:"delinquent"`
}

type Signature

type Signature [SignatureLength]byte

Signature The signature

func Base58ToSignature

func Base58ToSignature(b string) Signature

Base58ToSignature returns Signature with byte values of b.

func BytesToSignature

func BytesToSignature(b []byte) (s Signature)

BytesToSignature returns Signature with value b.

func StrToSignature

func StrToSignature(b string) Signature

StrToSignature returns Signature with byte values of b. Notice: only support base58/base64 str

func (Signature) Base58

func (s Signature) Base58() string

Base58 return base58 account

func (Signature) Bytes

func (s Signature) Bytes() []byte

Bytes return Signature bytes

func (Signature) ImplementsGraphQLType

func (s Signature) ImplementsGraphQLType(name string) bool

ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.

func (Signature) MarshalJSON added in v0.3.4

func (s Signature) MarshalJSON() ([]byte, error)

func (Signature) MarshalText

func (s Signature) MarshalText() ([]byte, error)

MarshalText returns base58 str account

func (*Signature) Scan

func (s *Signature) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (*Signature) SetBytes

func (s *Signature) SetBytes(b []byte)

SetBytes sets the PublicKey to the value of b.

func (Signature) Sign

func (s Signature) Sign(message []byte) []byte

func (Signature) String

func (s Signature) String() string

String return base58 account

func (*Signature) UnmarshalGraphQL

func (s *Signature) UnmarshalGraphQL(input interface{}) error

UnmarshalGraphQL unmarshals the provided GraphQL query dats.

func (*Signature) UnmarshalJSON

func (s *Signature) UnmarshalJSON(input []byte) error

UnmarshalJSON parses an account in base58 syntax.

func (*Signature) UnmarshalText

func (s *Signature) UnmarshalText(input []byte) error

UnmarshalText parses an account in base58 syntax.

func (Signature) Value

func (s Signature) Value() (driver.Value, error)

Value implements valuer for database/sql.

type SignatureInfo

type SignatureInfo struct {
	// transaction signature as base-58 encoded string
	Signature Signature `json:"signature,omitempty"`
	// The slot that contains the block with the transaction
	Slot uint64 `json:"slot"`
	// Error if transaction failed, null if transaction succeeded. See TransactionError definitions for more info.
	Err json.RawMessage `json:"err"`
	// Memo associated with the transaction, null if no memo is present
	Memo string `json:"memo,omitempty"`
	// estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available.
	BlockTime int64 `json:"blockTime,omitempty"`
	// The transaction's cluster confirmation status; Either processed, confirmed, or finalized.
	ConfirmationStatus string `json:"confirmationStatus,omitempty"`
}

type SignatureNotifies

type SignatureNotifies struct {
	Context ContextSlot `json:"context"`
	Value   interface{} `json:"value"`
}

type SignatureStatus

type SignatureStatus struct {
	// The slot that contains the block with the transaction
	Slot uint64 `json:"slot"`
	// Error if transaction failed, null if transaction succeeded. See TransactionError definitions for more info.
	Err json.RawMessage `json:"err"`
	// estimated production time, as Unix timestamp (seconds since the Unix epoch) of when transaction was processed. null if not available.
	Confirmations *uint64 `json:"confirmations,omitempty"`
	// The transaction's cluster confirmation status; Either processed, confirmed, or finalized.
	ConfirmationStatus string `json:"confirmationStatus,omitempty"`
}

type SignatureStatusWithCtx

type SignatureStatusWithCtx struct {
	Context         ContextSlot       `json:"context"`
	SignatureStatus []SignatureStatus `json:"value,omitempty"`
}

type SimulateResult added in v0.3.3

type SimulateResult struct {
	Context ContextSlot    `json:"context"`
	Value   SimulationInfo `json:"value"`
}

type SimulateReturn added in v0.3.3

type SimulateReturn struct {
	ProgramID string  `json:"programId"`
	Data      SolData `json:"data"`
}

type SimulationInfo added in v0.3.3

type SimulationInfo struct {
	Accounts []AccountInfo `json:"accounts"`
	// Error if transaction failed, null if transaction succeeded.
	// https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24
	Err json.RawMessage `json:"err"`
	// Fee this transaction was charged
	Fee uint64 `json:"fee"`

	// Array of *big.Int account balances from before the transaction was processed
	PreBalances []*big.Int `json:"preBalances"`

	// Array of *big.Int account balances after the transaction was processed
	PostBalances []*big.Int `json:"postBalances"`

	// List of inner instructions or omitted if inner instruction recording
	// was not yet enabled during this transaction
	InnerInstructions []InnerInstruction `json:"innerInstructions"`

	// List of token balances from before the transaction was processed
	// or omitted if token balance recording was not yet enabled during this transaction
	PreTokenBalances []TokenBalance `json:"preTokenBalances"`

	// List of token balances from after the transaction was processed
	// or omitted if token balance recording was not yet enabled during this transaction
	PostTokenBalances []TokenBalance `json:"postTokenBalances"`

	LoadedAccountsDataSize *uint32         `json:"loadedAccountsDataSize"`
	LoadedAddresses        LoadedAddresses `json:"loadedAddresses"`
	// Array of string log messages or omitted if log message
	// recording was not yet enabled during this transaction
	Logs []string `json:"logs"`

	ReplacementBlockhash *LastBlock      `json:"replacementBlockhash"`
	ReturnData           *SimulateReturn `json:"returnData"`
	UnitsConsumed        *uint64         `json:"unitsConsumed"`
}

type SlotNotifies

type SlotNotifies struct {
	Parent uint64 `json:"parent"`
	Root   uint64 `json:"root"`
	Slot   uint64 `json:"slot"`
}

type SlotRange

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

SlotRange the first slot --> lastSlot

type SolData

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

SolData base58, base64 data

func BytesToSolData

func BytesToSolData(data []byte) (sd SolData)

BytesToSolData default base58

func (SolData) Base58

func (sd SolData) Base58() string

Base58 return base58 str

func (SolData) Base64

func (sd SolData) Base64() string

func (SolData) Encoding

func (sd SolData) Encoding() EncodingEnum

func (SolData) MarshalJSON added in v0.3.4

func (sd SolData) MarshalJSON() ([]byte, error)

func (SolData) MarshalText

func (sd SolData) MarshalText() ([]byte, error)

MarshalText returns base58/base64 str

func (SolData) MarshalWithEncoder added in v0.3.4

func (sd SolData) MarshalWithEncoder(encoder *bin.Encoder) (err error)

func (SolData) RawData

func (sd SolData) RawData() []byte

func (*SolData) SetBytes

func (sd *SolData) SetBytes(input []byte)

SetBytes sets the SolData to the value of sd. (default base58)

func (*SolData) SetSolData

func (sd *SolData) SetSolData(data []byte, encoding EncodingEnum)

SetSolData sets the SolData

func (SolData) String

func (sd SolData) String() string

String return base58 str

func (*SolData) UnmarshalJSON

func (sd *SolData) UnmarshalJSON(input []byte) error

UnmarshalJSON parses data in base58 syntax.

func (*SolData) UnmarshalText

func (sd *SolData) UnmarshalText(input []byte) error

UnmarshalText parses data in base58 syntax.

func (*SolData) UnmarshalWithDecoder added in v0.3.4

func (sd *SolData) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)

func (SolData) Value

func (sd SolData) Value() (driver.Value, error)

Value implements valuer for database/sql.

type SolVersion

type SolVersion struct {
	// software version of solana-core as a string
	SolanaCore string `json:"solana-core"`
	// unique identifier of the current software's feature set as a u32
	FeatureSet uint32 `json:"feature-set"`
}

type StakeActivation

type StakeActivation struct {
	// the stake account's activation state, either: active, inactive, activating, or deactivating
	State string `json:"state"`
	// stake active during the epoch
	Active uint64 `json:"active"`
	// stake inactive during the epoch
	Inactive uint64 `json:"inactive"`
}

type Subscription

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.

type SupplyInfo

type SupplyInfo struct {
	// Total supply in lamports
	Total uint64 `json:"total"`
	// Circulating supply in lamports
	Circulating uint64 `json:"circulating"`
	// Non-circulating supply in lamports
	NonCirculating uint64 `json:"nonCirculating"`
	// an array of account addresses of non-circulating accounts, as strings. If excludeNonCirculatingAccountsList is enabled, the returned array will be empty.
	NonCirculatingAccounts []PublicKey `json:"nonCirculatingAccounts"`
}

type SupplyWithCtx

type SupplyWithCtx struct {
	Context ContextSlot `json:"context"`
	Supply  SupplyInfo  `json:"value"`
}

type TokenAccount

type TokenAccount struct {
	Account AccountInfo `json:"account"`
	Pubkey  PublicKey   `json:"pubkey,omitempty"`
}

type TokenAccountWithCtx

type TokenAccountWithCtx struct {
	Context ContextSlot   `json:"context"`
	UiToken UiTokenAmount `json:"value"`
}

type TokenAccountsWithCtx

type TokenAccountsWithCtx struct {
	Context  ContextSlot    `json:"context"`
	Accounts []TokenAccount `json:"value"`
}

type TokenBalance

type TokenBalance struct {
	// Index of the account in which the token balance is provided for.
	AccountIndex uint16 `json:"accountIndex"`

	// Pubkey of the token's mint.
	Mint PublicKey `json:"mint"`

	// Pubkey of token balance's owner.
	Owner PublicKey `json:"owner"`

	// ProgramId
	ProgramId string `json:"programId"`

	UiTokenAmount UiTokenAmount `json:"uiTokenAmount"`
}

type TokenLargestHolders

type TokenLargestHolders struct {
	Context ContextSlot     `json:"context"`
	Holders []UiTokenAmount `json:"value"`
}

type Transaction

type Transaction struct {
	// A list of base-58 encoded signatures applied to the transaction.
	// The list is always of length `message.header.numRequiredSignatures` and not empty.
	// The signature at index `i` corresponds to the public key at index
	// `i` in `message.account_keys`. The first one is used as the transaction id.
	Signatures []Signature `json:"signatures"`

	// Defines the content of the transaction.
	Message Message `json:"message"`
}

func NewTransaction

func NewTransaction(instructions []Instruction, recentBlockHash Hash, payer PublicKey) (*Transaction, error)

func (*Transaction) MarshalBinary

func (tx *Transaction) MarshalBinary() ([]byte, error)

func (*Transaction) NoSignedMarshalBinary

func (tx *Transaction) NoSignedMarshalBinary() ([]byte, error)

func (*Transaction) Sign

func (tx *Transaction) Sign(accounts []Account) ([]byte, error)

Sign accounts

func (Transaction) ToBase58

func (tx Transaction) ToBase58() (string, error)

func (Transaction) ToBase64

func (tx Transaction) ToBase64() (string, error)

func (*Transaction) UnmarshalBase58

func (tx *Transaction) UnmarshalBase58(b58 string) error

UnmarshalBase58 decodes a base58 encoded transaction.

func (*Transaction) UnmarshalBase64

func (tx *Transaction) UnmarshalBase64(b64 string) error

UnmarshalBase64 decodes a base64 encoded transaction.

func (*Transaction) UnmarshalJSON

func (tx *Transaction) UnmarshalJSON(input []byte) error

UnmarshalJSON parses the transaction Content

func (*Transaction) UnmarshalWithDecoder

func (tx *Transaction) UnmarshalWithDecoder(decoder *encodbin.Decoder) (err error)

type TransactionInfo

type TransactionInfo struct {
	// Transaction status metadata object
	Meta *TransactionMeta `json:"meta"`
	// The slot this transaction was processed in.
	Slot uint64 `json:"slot"`

	// Estimated production time, as Unix timestamp (seconds since the Unix epoch)
	// of when the transaction was processed.
	// Nil if not available.
	BlockTime *int64 `json:"blockTime" bin:"optional"`

	// Transaction
	Transaction *Transaction `json:"transaction"`
	// Version Of Transaction
	Version TxVersion `json:"version"`
}

type TransactionMeta

type TransactionMeta struct {
	// TODO if has zero ComputeUnitsConsumed
	ComputeUnitsConsumed *uint64 `json:"computeUnitsConsumed"`
	// Error if transaction failed, null if transaction succeeded.
	// https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24
	Err json.RawMessage `json:"err"`

	// Fee this transaction was charged
	Fee uint64 `json:"fee"`

	// Array of *big.Int account balances from before the transaction was processed
	PreBalances []*big.Int `json:"preBalances"`

	// Array of *big.Int account balances after the transaction was processed
	PostBalances []*big.Int `json:"postBalances"`

	// List of inner instructions or omitted if inner instruction recording
	// was not yet enabled during this transaction
	InnerInstructions []InnerInstruction `json:"innerInstructions"`

	// List of token balances from before the transaction was processed
	// or omitted if token balance recording was not yet enabled during this transaction
	PreTokenBalances []TokenBalance `json:"preTokenBalances"`

	// List of token balances from after the transaction was processed
	// or omitted if token balance recording was not yet enabled during this transaction
	PostTokenBalances []TokenBalance `json:"postTokenBalances"`

	// Array of string log messages or omitted if log message
	// recording was not yet enabled during this transaction
	LogMessages []string `json:"logMessages"`

	// Transaction status.
	Status TxStatus `json:"status"`

	Rewards []BlockReward `json:"rewards"`

	LoadedAddresses LoadedAddresses `json:"loadedAddresses"`
}

type TxStatus

type TxStatus struct {
	Ok  interface{}     `json:"Ok"`
	Err json.RawMessage `json:"Err"`
}

type TxVersion

type TxVersion int
const (
	LegacyTransactionVersion TxVersion = -1
)

func (TxVersion) MarshalJSON

func (ver TxVersion) MarshalJSON() ([]byte, error)

func (*TxVersion) UnmarshalJSON

func (ver *TxVersion) UnmarshalJSON(b []byte) error

type U64ValueWithCtx

type U64ValueWithCtx struct {
	Context ContextSlot `json:"context"`
	Value   *uint64     `json:"value,omitempty"`
}

type UiTokenAmount

type UiTokenAmount struct {
	// Address account
	Address *PublicKey `json:"address,omitempty"`

	// Raw amount of tokens as a string, ignoring decimals.
	Amount string `json:"amount"`

	// Number of decimals configured for token's mint.
	Decimals uint8 `json:"decimals"`

	// Token amount as a float, accounting for decimals.
	UiAmount float64 `json:"uiAmount"`

	// Token amount as a string, accounting for decimals.
	UiAmountString string `json:"uiAmountString"`
}

type Uint8Slice added in v0.3.6

type Uint8Slice []uint8

Uint8Slice is a slice of uint8s that can be marshaled as numbers instead of a byte slice.

func (Uint8Slice) MarshalJSON added in v0.3.6

func (u8s Uint8Slice) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

type VoteAccount

type VoteAccount struct {
	// Vote account address, as base-58 encoded string
	VotePubkey PublicKey `json:"votePubkey"`
	// Validator identity, as base-58 encoded string
	NodePubkey PublicKey `json:"nodePubkey"`
	// the stake, in lamports, delegated to this vote account and active in this epoch
	ActivatedStake uint64 `json:"activatedStake"`
	// bool, whether the vote account is staked for this epoch
	EpochVoteAccount bool `json:"epochVoteAccount"`
	// percentage (0-100) of rewards payout owed to the vote account
	Commission uint8 `json:"commission"`
	// Most recent slot voted on by this vote account
	LastVote uint64 `json:"lastVote"`
	// Latest history of earned credits for up to five epochs, as an array of arrays containing: [epoch, credits, previousCredits].
	EpochCredits [][]uint64 `json:"epochCredits"`
	// Current root slot for this vote
	RootSlot uint64 `json:"rootSlot"`
}

type WsClient added in v0.3.1

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

WsClient defines typed wrappers for the Solana RPC Subscribe.

func DialWs added in v0.3.1

func DialWs(rawurl string) (*WsClient, error)

DialWs connects a client to the given URL.

func DialWsContext added in v0.3.1

func DialWsContext(ctx context.Context, rawurl string) (*WsClient, error)

DialWsContext connects a client to the given URL with context.

func NewWsClient added in v0.3.1

func NewWsClient(c *rpc.Client) *WsClient

NewWsClient creates a client that uses the given RPC client.

func (*WsClient) AccountSubscribe added in v0.3.1

func (sc *WsClient) AccountSubscribe(ctx context.Context, ch chan<- AccountNotifies, account PublicKey, cfg ...RpcCommitmentWithEncodingCfg) (Subscription, error)

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

func (*WsClient) BlockSubscribe added in v0.3.1

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

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

func (*WsClient) LogsSubscribe added in v0.3.1

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

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

func (*WsClient) ProgramSubscribe added in v0.3.1

func (sc *WsClient) ProgramSubscribe(ctx context.Context, ch chan<- ProgramNotifies, address PublicKey, cfg ...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 (*WsClient) SignatureSubscribe added in v0.3.1

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

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

func (*WsClient) SlotSubscribe added in v0.3.1

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

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

Directories

Path Synopsis
core
spltoken
Package field implements fast arithmetic modulo 2^255-19.
Package field implements fast arithmetic modulo 2^255-19.
pkg

Jump to

Keyboard shortcuts

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