Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeInstruction(programID PublicKey, accounts []*AccountMeta, data []byte) (interface{}, error)
- func NewRandomPrivateKey() (PublicKey, PrivateKey, error)
- func RegisterInstructionDecoder(programID PublicKey, decoder InstructionDecoder)
- type Account
- type AccountInfo
- type AccountKey
- type AccountMeta
- type AccountSettable
- type Base58
- type BlockReward
- type BorshString
- type ByteWrapper
- type CommitmentType
- type CompiledInstruction
- type Context
- type Data
- type FeeCalculator
- type FeeResult
- type GetAccountInfoResult
- type GetBalanceResult
- type GetBlockResult
- type GetEpochInfoResult
- type GetFeesResult
- type GetLatestBlockhashResult
- type GetNonceAccountInfoResult
- type GetProgramAccountsOpts
- type GetProgramAccountsResult
- type GetRecentBlockhashResult
- type GetSignatureStatusesResult
- type GetSignaturesForAddressOpts
- type GetSignaturesForAddressResult
- type GetSlotResult
- type GetTokenAmountResult
- type Hash
- type InstructionDecoder
- type InstructionInfo
- type KeyedAccount
- type LatestBlockhashResult
- type Message
- func (m *Message) AccountMetaList() (out []*AccountMeta)
- func (m *Message) IsSigner(account PublicKey) bool
- func (m *Message) IsWritable(account PublicKey) bool
- func (m *Message) ResolveProgramIDIndex(programIDIndex uint8) (PublicKey, error)
- func (m *Message) Serialize() ([]byte, error)
- func (m *Message) SignerKeys() []PublicKey
- func (m *Message) TouchAccount(account PublicKey) bool
- type MessageHeader
- type NonceAccountData
- type NonceAccountFee
- type NonceAccountInfo
- type NonceAccountParsed
- type NonceAccountValue
- type Padding
- type ParsedInstruction
- type ParsedTransaction
- type PrivateKey
- type PublicKey
- func FindAssociatedTokenAddress(walletAddress, tokenMintAddress PublicKey) (PublicKey, error)
- func MustPublicKeyFromBase58(in string) PublicKey
- func PublicKeyFindProgramAddress(seeds [][]byte, programID PublicKey) (PublicKey, byte, error)
- func PublicKeyFromBase58(in string) (out PublicKey, err error)
- func PublicKeyFromBytes(in []byte) (out PublicKey)
- func (p PublicKey) Equals(pb PublicKey) bool
- func (p PublicKey) IsZero() bool
- func (p PublicKey) MarshalJSON() ([]byte, error)
- func (p PublicKey) String() string
- func (p PublicKey) ToSlice() []byte
- func (p *PublicKey) UnmarshalJSON(data []byte) (err error)
- func (p PublicKey) VerifySignature(message, sig []byte) bool
- type RPCContext
- type RPCFilter
- type RPCFilterMemcmp
- type RPCMessage
- type RecentBlockhashResult
- type SendTransactionOptions
- type Signature
- type SignatureStatus
- type SimulateTransactionResponse
- type TokenAmountResult
- type TokenBalances
- type Transaction
- func (t *Transaction) AccountMetaList() (out []*AccountMeta)
- func (t *Transaction) IsSigner(account PublicKey) bool
- func (t *Transaction) IsWritable(account PublicKey) bool
- func (t *Transaction) ResolveProgramIDIndex(programIDIndex uint8) (PublicKey, error)
- func (t *Transaction) Serialize(signdata []byte) ([]byte, error)
- func (t *Transaction) SerializeAll() ([]byte, error)
- func (t *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
- func (t *Transaction) TouchAccount(account PublicKey) bool
- type TransactionInstruction
- type TransactionMeta
- type TransactionOption
- type TransactionParsed
- type TransactionSignature
- type TransactionWithMeta
- type Uint8Arr
Constants ¶
const ( MaxSeeds = 16 MaxSeedLength = 32 PDAMarker = "ProgramDerivedAddress" )
constants
const ( // CommitmentProcessed queries the most recent block which has reached 1 confirmation by the connected node CommitmentProcessed = CommitmentType("processed") // CommitmentConfirmed queries the most recent block which has reached 1 confirmation by the cluster CommitmentConfirmed = CommitmentType("confirmed") // CommitmentFinalized queries the most recent block which has been finalized by the cluster CommitmentFinalized = CommitmentType("finalized") )
commitment contants
Variables ¶
var ( TokenProgramID = MustPublicKeyFromBase58("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") ATAProgramID = MustPublicKeyFromBase58("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL") )
known program IDs
var InstructionDecoderRegistry = map[string]InstructionDecoder{}
InstructionDecoderRegistry instruction decoder registry
Functions ¶
func DecodeInstruction ¶
func DecodeInstruction(programID PublicKey, accounts []*AccountMeta, data []byte) (interface{}, error)
DecodeInstruction decode instruction
func NewRandomPrivateKey ¶
func NewRandomPrivateKey() (PublicKey, PrivateKey, error)
NewRandomPrivateKey new random private key
func RegisterInstructionDecoder ¶
func RegisterInstructionDecoder(programID PublicKey, decoder InstructionDecoder)
RegisterInstructionDecoder register instruction decoder
Types ¶
type Account ¶
type Account struct {
PrivateKey PrivateKey
}
Account account type
func AccountFromPrivateKeyBase58 ¶
AccountFromPrivateKeyBase58 account from private key base58
type AccountInfo ¶
type AccountInfo struct { Lamports bin.Uint64 `json:"lamports"` Data interface{} `json:"data"` // <[string, encoding]|object> Owner PublicKey `json:"owner"` Executable bool `json:"executable"` RentEpoch bin.Uint64 `json:"rentEpoch"` }
AccountInfo account info
type AccountKey ¶
type AccountKey struct { PublicKey PublicKey `json:"pubkey"` Signer bool `json:"signer"` Writable bool `json:"writable"` }
AccountKey account key
type AccountMeta ¶
AccountMeta account meta type
type AccountSettable ¶
type AccountSettable interface {
SetAccounts(accounts []*AccountMeta) error
}
AccountSettable interface
type Base58 ¶
type Base58 []byte
Base58 bytes
func (*Base58) UnmarshalJSON ¶
UnmarshalJSON json unmarshal
type BlockReward ¶
BlockReward block reward
type BorshString ¶
BorshString borsh string
func ToBorshString ¶
func ToBorshString(str string) BorshString
ToBorshString to borsh encoded string
func (BorshString) MarshalJSON ¶
func (s BorshString) MarshalJSON() ([]byte, error)
MarshalJSON json marshal
func (*BorshString) String ¶
func (s *BorshString) String() string
func (*BorshString) UnmarshalJSON ¶
func (s *BorshString) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON json unmarshal
type ByteWrapper ¶
ByteWrapper type
type CommitmentType ¶
type CommitmentType string
CommitmentType is the level of commitment desired when querying state. https://docs.com/developing/clients/jsonrpc-api#configuring-state-commitment
type CompiledInstruction ¶
type CompiledInstruction struct { ProgramIDIndex uint8 `json:"programIdIndex"` AccountCount bin.Varuint16 `json:"-" bin:"sizeof=Accounts"` Accounts Uint8Arr `json:"accounts"` DataLength bin.Varuint16 `json:"-" bin:"sizeof=Data"` Data Base58 `json:"data"` }
CompiledInstruction type
func (*CompiledInstruction) ResolveInstructionAccounts ¶
func (ci *CompiledInstruction) ResolveInstructionAccounts(message *Message) (out []*AccountMeta)
ResolveInstructionAccounts resolve instruction accounts
type FeeCalculator ¶
FeeCalculator fee calculator
type FeeResult ¶
type FeeResult struct { Blockhash Hash `json:"blockhash"` FeeCalculator FeeCalculator `json:"feeCalculator"` LastValidBlockHeight bin.Uint64 `json:"lastValidBlockHeight"` LastValidSlot bin.Uint64 `json:"lastValidSlot"` }
FeeResult fee result
type GetAccountInfoResult ¶
type GetAccountInfoResult struct { RPCContext Value *AccountInfo `json:"value"` }
GetAccountInfoResult get account info result
type GetBalanceResult ¶
type GetBalanceResult struct { RPCContext Value bin.Uint64 `json:"value"` }
GetBalanceResult get balance result
type GetBlockResult ¶
type GetBlockResult struct { Blockhash Hash `json:"blockhash"` PreviousBlockhash Hash `json:"previousBlockhash"` ParentSlot bin.Uint64 `json:"parentSlot"` Transactions []TransactionWithMeta `json:"transactions,omitempty"` Signatures []Signature `json:"signatures,omitempty"` Rewards []BlockReward `json:"rewards"` BlockTime bin.Uint64 `json:"blockTime,omitempty"` }
GetBlockResult get block result
type GetEpochInfoResult ¶
type GetFeesResult ¶
type GetFeesResult struct { RPCContext Value FeeResult `json:"value"` }
GetFeesResult get fees result
type GetLatestBlockhashResult ¶
type GetLatestBlockhashResult struct { RPCContext Value LatestBlockhashResult `json:"value"` }
GetLatestBlockhashResult get latest block hash result
type GetNonceAccountInfoResult ¶
type GetNonceAccountInfoResult struct { RPCContext Value *NonceAccountValue `json:"value"` }
GetNonceAccountInfoResult get account info result
type GetProgramAccountsOpts ¶
type GetProgramAccountsOpts struct { Commitment CommitmentType `json:"commitment,omitempty"` // Filter on accounts, implicit AND between filters Filters []RPCFilter `json:"filters,omitempty"` }
GetProgramAccountsOpts get program account options
type GetProgramAccountsResult ¶
type GetProgramAccountsResult []*KeyedAccount
GetProgramAccountsResult get program accounts result
type GetRecentBlockhashResult ¶
type GetRecentBlockhashResult struct { RPCContext Value RecentBlockhashResult `json:"value"` }
GetRecentBlockhashResult get recent block hash result DEPRECATED: Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0
type GetSignatureStatusesResult ¶
type GetSignatureStatusesResult struct { RPCContext Value []SignatureStatus `json:"value"` }
GetSignatureStatusesResult result
type GetSignaturesForAddressOpts ¶
type GetSignaturesForAddressOpts struct { Limit uint64 `json:"limit,omitempty"` Before string `json:"before,omitempty"` Until string `json:"until,omitempty"` }
GetSignaturesForAddressOpts get signatures for address opts
type GetSignaturesForAddressResult ¶
type GetSignaturesForAddressResult []*TransactionSignature
GetSignaturesForAddressResult get signatures for address result
type GetTokenAmountResult ¶
type GetTokenAmountResult struct { RPCContext Value TokenAmountResult `json:"value"` }
GetTokenAmountResult get token amount result including get token account balance and get token supply
type InstructionDecoder ¶
type InstructionDecoder func(instructionAccounts []*AccountMeta, data []byte) (interface{}, error)
InstructionDecoder receives the AccountMeta FOR THAT INSTRUCTION, and not the accounts of the *Message object. Resolve with CompiledInstruction.ResolveInstructionAccounts(message) beforehand.
type InstructionInfo ¶
type InstructionInfo struct { Info map[string]interface{} `json:"info"` InstructionType string `json:"type"` }
InstructionInfo instruction info
type KeyedAccount ¶
type KeyedAccount struct { Pubkey PublicKey `json:"pubkey"` Account *AccountInfo `json:"account"` }
KeyedAccount keyed account
type LatestBlockhashResult ¶
type LatestBlockhashResult struct { Blockhash Hash `json:"blockhash"` LastValidBlockHeight bin.Uint64 `json:"lastValidBlockHeight"` }
LatestBlockhashResult latest block hash result
type Message ¶
type Message struct { Header MessageHeader `json:"header"` AccountKeys []PublicKey `json:"accountKeys"` RecentBlockhash Hash `json:"recentBlockhash"` Instructions []CompiledInstruction `json:"instructions"` }
Message type
func (*Message) AccountMetaList ¶
func (m *Message) AccountMetaList() (out []*AccountMeta)
AccountMetaList get account meta list
func (*Message) IsWritable ¶
IsWritable is writable
func (*Message) ResolveProgramIDIndex ¶
ResolveProgramIDIndex resolve programID index
func (*Message) TouchAccount ¶
TouchAccount touch account
type MessageHeader ¶
type MessageHeader struct { NumRequiredSignatures uint8 `json:"numRequiredSignatures"` NumReadonlySignedAccounts uint8 `json:"numReadonlySignedAccounts"` NumReadonlyUnsignedAccounts uint8 `json:"numReadonlyUnsignedAccounts"` }
MessageHeader type
type NonceAccountData ¶
type NonceAccountData struct { Info *NonceAccountParsed `json:"parsed"` Program string `json:"program"` Space bin.Uint64 `json:"space"` }
type NonceAccountFee ¶
type NonceAccountFee struct {
LamportsPerSignature string `json:"lamportsPerSignature"`
}
type NonceAccountInfo ¶
type NonceAccountInfo struct { Authority string `json:"authority"` Blockhash string `json:"blockhash"` FeeCalculator *NonceAccountFee `json:"feeCalculator"` }
type NonceAccountParsed ¶
type NonceAccountParsed struct { Info *NonceAccountInfo `json:"info"` Type string `json:"type"` }
type NonceAccountValue ¶
type NonceAccountValue struct { Lamports bin.Uint64 `json:"lamports"` Data *NonceAccountData `json:"data"` // <[string, encoding]|object> Owner PublicKey `json:"owner"` Executable bool `json:"executable"` RentEpoch bin.Uint64 `json:"rentEpoch"` }
AccountInfo account info
type ParsedInstruction ¶
type ParsedInstruction struct { Accounts []PublicKey `json:"accounts,omitempty"` Data Base58 `json:"data,omitempty"` Parsed *InstructionInfo `json:"parsed,omitempty"` Program string `json:"program,omitempty"` ProgramID PublicKey `json:"programId"` }
ParsedInstruction parsed instruction
type ParsedTransaction ¶
type ParsedTransaction struct { Signatures []Signature `json:"signatures"` Message RPCMessage `json:"message"` }
ParsedTransaction parsed tx
type PrivateKey ¶
type PrivateKey []byte
PrivateKey bytes
func MustPrivateKeyFromBase58 ¶
func MustPrivateKeyFromBase58(in string) PrivateKey
MustPrivateKeyFromBase58 must decode private key from base58
func PrivateKeyFromBase58 ¶
func PrivateKeyFromBase58(privkey string) (PrivateKey, error)
PrivateKeyFromBase58 decode private key from base58
func PrivateKeyFromSolanaKeygenFile ¶
func PrivateKeyFromSolanaKeygenFile(file string) (PrivateKey, error)
PrivateKeyFromSolanaKeygenFile decode private key from file
func (PrivateKey) Sign ¶
func (k PrivateKey) Sign(payload []byte) (Signature, error)
Sign sign message
func (PrivateKey) String ¶
func (k PrivateKey) String() string
type PublicKey ¶
type PublicKey [32]byte
PublicKey bytes 32
func FindAssociatedTokenAddress ¶
FindAssociatedTokenAddress find associated token account
func MustPublicKeyFromBase58 ¶
MustPublicKeyFromBase58 must get public key from base58
func PublicKeyFindProgramAddress ¶
PublicKeyFindProgramAddress create derived addresses
func PublicKeyFromBase58 ¶
PublicKeyFromBase58 get public key from base58
func PublicKeyFromBytes ¶
PublicKeyFromBytes get public key from bytes
func (PublicKey) MarshalJSON ¶
MarshalJSON json marshal
func (*PublicKey) UnmarshalJSON ¶
UnmarshalJSON json unmarshal
func (PublicKey) VerifySignature ¶
VerifySignature verify signature
type RPCContext ¶
type RPCContext struct {
Context Context `json:"context,omitempty"`
}
RPCContext rpc context
type RPCFilter ¶
type RPCFilter struct { Memcmp *RPCFilterMemcmp `json:"memcmp,omitempty"` DataSize bin.Uint64 `json:"dataSize,omitempty"` }
RPCFilter type
type RPCFilterMemcmp ¶
RPCFilterMemcmp type
type RPCMessage ¶
type RPCMessage struct { AccountKeys []*AccountKey `json:"accountKeys"` RecentBlockhash Hash `json:"recentBlockhash"` Instructions []ParsedInstruction `json:"instructions"` }
RPCMessage type
type RecentBlockhashResult ¶
type RecentBlockhashResult struct { Blockhash Hash `json:"blockhash"` FeeCalculator FeeCalculator `json:"feeCalculator"` }
RecentBlockhashResult block hash result
type SendTransactionOptions ¶
type SendTransactionOptions struct { SkipPreflight bool // disable transaction verification step PreflightCommitment CommitmentType // preflight commitment level; default: "finalized" }
SendTransactionOptions send tx options
type Signature ¶
type Signature [64]byte
Signature 64 bytes
func MustSignatureFromString ¶
MustSignatureFromString must signature from string
func NewSignatureFromBase58 ¶
NewSignatureFromBase58 new signature from base58
func NewSignatureFromBytes ¶
NewSignatureFromBytes new signature from bytes
func NewSignatureFromString ¶
NewSignatureFromString new signature from string
func (Signature) MarshalJSON ¶
MarshalJSON json marshal
func (*Signature) UnmarshalJSON ¶
UnmarshalJSON json unmarshal
type SignatureStatus ¶
type SignatureStatus struct { Slot bin.Uint64 `json:"slot"` Confirmations *bin.Uint64 `json:"confirmations"` Err interface{} `json:"err"` ConfirmationStatus *string `json:"confirmationStatus"` }
SignatureStatus signature status
type SimulateTransactionResponse ¶
type SimulateTransactionResponse struct { Err interface{} `json:"err"` Logs []string `json:"logs"` }
SimulateTransactionResponse simulate tx responce
type TokenAmountResult ¶
type TokenAmountResult struct { Amount bin.Uint64 `json:"amount"` Decimals uint8 `json:"decimals"` UIAmountString string `json:"uiAmountString"` }
TokenAmountResult token amount result
type TokenBalances ¶
type TokenBalances struct { AccountIndex uint8 `json:"accountIndex"` Mint PublicKey `json:"mint"` Owner PublicKey `json:"owner"` UITokenAmount TokenAmountResult `json:"uiTokenAmount"` }
TokenBalances token balances
type Transaction ¶
type Transaction struct { Signatures []Signature `json:"signatures"` Message Message `json:"message"` }
Transaction type
func DecodeTransaction ¶
func DecodeTransaction(encodedStr string, encoding string) (*Transaction, error)
DecodeTransaction decode transaction
func NewTransaction ¶
func NewTransaction(instructions []TransactionInstruction, blockHash Hash, opts ...TransactionOption) (*Transaction, error)
NewTransaction new tx
func TransactionFromData ¶
func TransactionFromData(in []byte) (*Transaction, error)
TransactionFromData transaction from data
func (*Transaction) AccountMetaList ¶
func (t *Transaction) AccountMetaList() (out []*AccountMeta)
AccountMetaList get account meta list
func (*Transaction) IsSigner ¶
func (t *Transaction) IsSigner(account PublicKey) bool
IsSigner is signer
func (*Transaction) IsWritable ¶
func (t *Transaction) IsWritable(account PublicKey) bool
IsWritable is writable
func (*Transaction) ResolveProgramIDIndex ¶
func (t *Transaction) ResolveProgramIDIndex(programIDIndex uint8) (PublicKey, error)
ResolveProgramIDIndex resolve programID index
func (*Transaction) SerializeAll ¶
func (t *Transaction) SerializeAll() ([]byte, error)
func (*Transaction) Sign ¶
func (t *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
Sign sign with private key
func (*Transaction) TouchAccount ¶
func (t *Transaction) TouchAccount(account PublicKey) bool
TouchAccount touch account
type TransactionInstruction ¶
type TransactionInstruction interface { Accounts() []*AccountMeta // returns the list of accounts the instructions requires ProgramID() PublicKey // the programID the instruction acts on Data() ([]byte, error) // the binary encoded instructions }
TransactionInstruction interface
type TransactionMeta ¶
type TransactionMeta struct { Err interface{} `json:"err"` Fee bin.Uint64 `json:"fee"` PreBalances []bin.Uint64 `json:"preBalances,omitempty"` PostBalances []bin.Uint64 `json:"postBalances,omitempty"` PreTokenBalances []TokenBalances `json:"preTokenBalances,omitempty"` PostTokenBalances []TokenBalances `json:"postTokenBalances,omitempty"` LogMessages []string `json:"logMessages"` }
TransactionMeta tx meta
func (*TransactionMeta) IsStatusOk ¶
func (m *TransactionMeta) IsStatusOk() bool
IsStatusOk in status ok
type TransactionOption ¶
type TransactionOption interface {
// contains filtered or unexported methods
}
TransactionOption interface
func TransactionPayer ¶
func TransactionPayer(payer PublicKey) TransactionOption
TransactionPayer tx payer
type TransactionParsed ¶
type TransactionParsed struct { Transaction *ParsedTransaction `json:"transaction"` Meta *TransactionMeta `json:"meta,omitempty"` }
TransactionParsed tx parsed
type TransactionSignature ¶
type TransactionSignature struct { Err interface{} `json:"err,omitempty"` Memo string `json:"memo,omitempty"` Signature string `json:"signature,omitempty"` Slot bin.Uint64 `json:"slot,omitempty"` }
TransactionSignature tx signature
type TransactionWithMeta ¶
type TransactionWithMeta struct { Slot bin.Uint64 `json:"slot,omitempty"` Transaction *Transaction `json:"transaction"` BlockTime bin.Uint64 `json:"blockTime,omitempty"` Meta *TransactionMeta `json:"meta,omitempty"` }
TransactionWithMeta tx with meta
type Uint8Arr ¶
type Uint8Arr []uint8
Uint8Arr array of uint8 solve json marshal will encode '[]uint8' to string rather than an array of numbers
func (Uint8Arr) MarshalJSON ¶
MarshalJSON json marshal