Documentation ¶
Index ¶
- Constants
- Variables
- func DecimalsInBigInt(decimal uint32) *big.Int
- func DecodeInstruction(programID PublicKey, accounts []*AccountMeta, data []byte) (interface{}, error)
- func GetAddedRemovedPubkeys(previous PublicKeySlice, next PublicKeySlice) (added PublicKeySlice, removed PublicKeySlice)
- func IsAnyOfEncodingType(candidate EncodingType, allowed ...EncodingType) bool
- func IsOnCurve(b []byte) bool
- func RegisterInstructionDecoder(programID PublicKey, decoder InstructionDecoder)
- type AccountMeta
- type AccountMetaSlice
- func (slice *AccountMetaSlice) Append(account *AccountMeta)
- func (slice AccountMetaSlice) Get(index int) *AccountMeta
- func (slice AccountMetaSlice) GetAccounts() []*AccountMeta
- func (slice AccountMetaSlice) GetKeys() PublicKeySlice
- func (slice AccountMetaSlice) GetSigners() []*AccountMeta
- func (slice AccountMetaSlice) Len() int
- func (slice *AccountMetaSlice) SetAccounts(accounts []*AccountMeta) error
- func (slice AccountMetaSlice) SplitFrom(index int) (AccountMetaSlice, AccountMetaSlice)
- type AccountsGettable
- type AccountsSettable
- type Base58
- type ByteWrapper
- type CompiledInstruction
- type Data
- type DurationMilliseconds
- type DurationSeconds
- type EncodingType
- type GenericInstruction
- type Hash
- type Instruction
- type InstructionDecoder
- type Message
- func (m Message) Account(index uint16) (PublicKey, error)
- func (m Message) AccountMetaList() (AccountMetaSlice, error)
- func (mx *Message) AddAddressTableLookup(lookup MessageAddressTableLookup) *Message
- func (mx *Message) EncodeToTree(txTree treeout.Branches)
- func (mx Message) GetAddressTableLookupAccounts() ([]PublicKey, error)
- func (mx *Message) GetAddressTableLookups() MessageAddressTableLookupSlice
- func (mx *Message) GetAddressTables() map[PublicKey]PublicKeySlice
- func (mx Message) GetAllKeys() (keys PublicKeySlice, err error)
- func (m *Message) GetVersion() MessageVersion
- func (m Message) HasAccount(account PublicKey) (bool, error)
- func (m Message) IsSigner(account PublicKey) bool
- func (m Message) IsVersioned() bool
- func (m Message) IsWritable(account PublicKey) (bool, error)
- func (mx *Message) MarshalBinary() ([]byte, error)
- func (mx Message) MarshalJSON() ([]byte, error)
- func (mx *Message) MarshalLegacy() ([]byte, error)
- func (mx *Message) MarshalV0() ([]byte, error)
- func (mx Message) MarshalWithEncoder(encoder *bin.Encoder) error
- func (mx Message) NumLookups() int
- func (mx Message) NumWritableLookups() int
- func (m Message) Program(programIDIndex uint16) (PublicKey, error)
- func (mx *Message) ResolveLookups() (err error)
- func (m Message) ResolveProgramIDIndex(programIDIndex uint16) (PublicKey, error)
- func (mx *Message) SetAddressTableLookups(lookups []MessageAddressTableLookup) *Message
- func (mx *Message) SetAddressTables(tables map[PublicKey]PublicKeySlice) error
- func (m *Message) SetVersion(version MessageVersion) *Message
- func (m Message) Signers() PublicKeySlice
- func (mx Message) ToBase64() string
- func (mx *Message) UnmarshalBase64(b64 string) error
- func (mx *Message) UnmarshalLegacy(decoder *bin.Decoder) (err error)
- func (mx *Message) UnmarshalV0(decoder *bin.Decoder) (err error)
- func (mx *Message) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)
- func (m Message) Writable() (out PublicKeySlice, err error)
- type MessageAddressTableLookup
- type MessageAddressTableLookupSlice
- type MessageHeader
- type MessageVersion
- type PK
- type Padding
- type PrivateKey
- type PublicKey
- func CreateProgramAddress(seeds [][]byte, programID PublicKey) (PublicKey, error)
- func CreateWithSeed(base PublicKey, seed string, owner PublicKey) (PublicKey, error)
- func FindAssociatedTokenAddress(wallet PublicKey, mint PublicKey) (PublicKey, uint8, error)
- func FindProgramAddress(seed [][]byte, programID PublicKey) (PublicKey, uint8, error)
- func FindTokenMetadataAddress(mint PublicKey) (PublicKey, uint8, error)
- func MPK(in string) PublicKey
- func MustPublicKeyFromBase58(in string) PublicKey
- func PublicKeyFromBase58(in string) (out PublicKey, err error)
- func PublicKeyFromBytes(in []byte) (out PublicKey)
- func (p PublicKey) Bytes() []byte
- func (p PublicKey) Equals(pb PublicKey) bool
- func (p PublicKey) IsAnyOf(keys ...PublicKey) bool
- func (p PublicKey) IsOnCurve() bool
- func (p PublicKey) IsZero() bool
- func (p PublicKey) MarshalBSON() ([]byte, error)
- func (p PublicKey) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (p PublicKey) MarshalJSON() ([]byte, error)
- func (p PublicKey) MarshalText() ([]byte, error)
- func (p *PublicKey) Set(s string) (err error)
- func (p PublicKey) Short(n int) string
- func (p PublicKey) String() string
- func (p PublicKey) ToPointer() *PublicKey
- func (p *PublicKey) UnmarshalBSON(data []byte) (err error)
- func (p *PublicKey) UnmarshalBSONValue(t bsontype.Type, data []byte) (err error)
- func (p *PublicKey) UnmarshalJSON(data []byte) (err error)
- func (p *PublicKey) UnmarshalText(data []byte) error
- func (p PublicKey) Verify(message []byte, signature Signature) bool
- type PublicKeySlice
- func (a PublicKeySlice) Added(b PublicKeySlice) PublicKeySlice
- func (slice *PublicKeySlice) Append(pubkeys ...PublicKey)
- func (slice PublicKeySlice) Contains(pubkey PublicKey) bool
- func (slice PublicKeySlice) ContainsAll(pubkeys PublicKeySlice) bool
- func (slice PublicKeySlice) ContainsAny(pubkeys PublicKeySlice) bool
- func (slice PublicKeySlice) Dedupe() PublicKeySlice
- func (slice PublicKeySlice) Equals(other PublicKeySlice) bool
- func (slice PublicKeySlice) First() *PublicKey
- func (prev PublicKeySlice) GetAddedRemoved(next PublicKeySlice) (added PublicKeySlice, removed PublicKeySlice)
- func (slice PublicKeySlice) Has(pubkey PublicKey) bool
- func (prev PublicKeySlice) Intersect(next PublicKeySlice) PublicKeySlice
- func (slice PublicKeySlice) Last() *PublicKey
- func (slice PublicKeySlice) Len() int
- func (slice PublicKeySlice) Less(i, j int) bool
- func (a PublicKeySlice) Removed(b PublicKeySlice) PublicKeySlice
- func (slice PublicKeySlice) Same(other PublicKeySlice) bool
- func (slice PublicKeySlice) Sort()
- func (slice PublicKeySlice) Split(chunkSize int) []PublicKeySlice
- func (slice PublicKeySlice) Swap(i, j int)
- func (slice PublicKeySlice) ToBase58() []string
- func (slice PublicKeySlice) ToBytes() [][]byte
- func (slice PublicKeySlice) ToPointers() []*PublicKey
- func (slice *PublicKeySlice) UniqueAppend(pubkey PublicKey) bool
- type Signature
- func (sig Signature) Equals(pb Signature) bool
- func (sig Signature) IsZero() bool
- func (p Signature) MarshalJSON() ([]byte, error)
- func (p Signature) MarshalText() ([]byte, error)
- func (p Signature) String() string
- func (p *Signature) UnmarshalJSON(data []byte) (err error)
- func (p *Signature) UnmarshalText(data []byte) (err error)
- func (s Signature) Verify(pubkey PublicKey, msg []byte) bool
- type Transaction
- func (t *Transaction) AccountMetaList() ([]*AccountMeta, error)
- func (tx *Transaction) EncodeToTree(parent treeout.Branches)
- func (tx *Transaction) EncodeTree(encoder *text.TreeEncoder) (int, error)
- func (t *Transaction) HasAccount(account PublicKey) (bool, error)
- func (t *Transaction) IsSigner(account PublicKey) bool
- func (t *Transaction) IsWritable(account PublicKey) (bool, error)
- func (tx *Transaction) MarshalBinary() ([]byte, error)
- func (tx Transaction) MarshalWithEncoder(encoder *bin.Encoder) error
- func (tx Transaction) MustToBase64() string
- func (tx *Transaction) PartialSign(getter privateKeyGetter) (out []Signature, err error)
- func (t *Transaction) ResolveProgramIDIndex(programIDIndex uint16) (PublicKey, error)
- func (tx *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
- func (tx *Transaction) String() string
- func (tx Transaction) ToBase64() (string, error)
- func (tx *Transaction) UnmarshalBase64(b64 string) error
- func (tx *Transaction) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)
- func (tx *Transaction) VerifySignatures() error
- type TransactionBuilder
- func (builder *TransactionBuilder) AddInstruction(instruction Instruction) *TransactionBuilder
- func (builder *TransactionBuilder) Build() (*Transaction, error)
- func (builder *TransactionBuilder) SetFeePayer(feePayer PublicKey) *TransactionBuilder
- func (builder *TransactionBuilder) SetRecentBlockHash(recentBlockHash Hash) *TransactionBuilder
- func (builder *TransactionBuilder) WithOpt(opt TransactionOption) *TransactionBuilder
- type TransactionOption
- type Uint8SliceAsNum
- type UnixTimeMilliseconds
- type UnixTimeSeconds
- type Wallet
Constants ¶
const ( /// Number of bytes in a pubkey. PublicKeyLength = 32 // Maximum length of derived pubkey seed. MaxSeedLength = 32 // Maximum number of seeds. MaxSeeds = 16 /// Number of bytes in a signature. SignatureLength = 64 )
const ( // There are 1-billion lamports in one SOL. LAMPORTS_PER_SOL uint64 = 1000000000 )
const PDA_MARKER = "ProgramDerivedAddress"
Variables ¶
var ( // Create new accounts, allocate account data, assign accounts to owning programs, // transfer lamports from System Program owned accounts and pay transacation fees. SystemProgramID = MustPublicKeyFromBase58("11111111111111111111111111111111") // Add configuration data to the chain and the list of public keys that are permitted to modify it. ConfigProgramID = MustPublicKeyFromBase58("Config1111111111111111111111111111111111111") // Create and manage accounts representing stake and rewards for delegations to validators. StakeProgramID = MustPublicKeyFromBase58("Stake11111111111111111111111111111111111111") // Create and manage accounts that track validator voting state and rewards. VoteProgramID = MustPublicKeyFromBase58("Vote111111111111111111111111111111111111111") BPFLoaderDeprecatedProgramID = MustPublicKeyFromBase58("BPFLoader1111111111111111111111111111111111") // Deploys, upgrades, and executes programs on the chain. BPFLoaderProgramID = MustPublicKeyFromBase58("BPFLoader2111111111111111111111111111111111") BPFLoaderUpgradeableProgramID = MustPublicKeyFromBase58("BPFLoaderUpgradeab1e11111111111111111111111") // Verify secp256k1 public key recovery operations (ecrecover). Secp256k1ProgramID = MustPublicKeyFromBase58("KeccakSecp256k11111111111111111111111111111") FeatureProgramID = MustPublicKeyFromBase58("Feature111111111111111111111111111111111111") ComputeBudget = MustPublicKeyFromBase58("ComputeBudget111111111111111111111111111111") )
var ( // A Token program on the Solana blockchain. // This program defines a common implementation for Fungible and Non Fungible tokens. TokenProgramID = MustPublicKeyFromBase58("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") // A Uniswap-like exchange for the Token program on the Solana blockchain, // implementing multiple automated market maker (AMM) curves. TokenSwapProgramID = MustPublicKeyFromBase58("SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8") TokenSwapFeeOwner = MustPublicKeyFromBase58("HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN") // A lending protocol for the Token program on the Solana blockchain inspired by Aave and Compound. TokenLendingProgramID = MustPublicKeyFromBase58("LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi") // This program defines the convention and provides the mechanism for mapping // the user's wallet address to the associated token accounts they hold. SPLAssociatedTokenAccountProgramID = MustPublicKeyFromBase58("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL") // The Memo program is a simple program that validates a string of UTF-8 encoded characters // and verifies that any accounts provided are signers of the transaction. // The program also logs the memo, as well as any verified signer addresses, // to the transaction log, so that anyone can easily observe memos // and know they were approved by zero or more addresses // by inspecting the transaction log from a trusted provider. MemoProgramID = MustPublicKeyFromBase58("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr") )
SPL:
var ( // The Mint for native SOL Token accounts SolMint = MustPublicKeyFromBase58("So11111111111111111111111111111111111111112") WrappedSol = SolMint )
var ( // The Clock sysvar contains data on cluster time, // including the current slot, epoch, and estimated wall-clock Unix timestamp. // It is updated every slot. SysVarClockPubkey = MustPublicKeyFromBase58("SysvarC1ock11111111111111111111111111111111") // The EpochSchedule sysvar contains epoch scheduling constants that are set in genesis, // and enables calculating the number of slots in a given epoch, // the epoch for a given slot, etc. // (Note: the epoch schedule is distinct from the leader schedule) SysVarEpochSchedulePubkey = MustPublicKeyFromBase58("SysvarEpochSchedu1e111111111111111111111111") // The Fees sysvar contains the fee calculator for the current slot. // It is updated every slot, based on the fee-rate governor. SysVarFeesPubkey = MustPublicKeyFromBase58("SysvarFees111111111111111111111111111111111") // The Instructions sysvar contains the serialized instructions in a Message while that Message is being processed. // This allows program instructions to reference other instructions in the same transaction. SysVarInstructionsPubkey = MustPublicKeyFromBase58("Sysvar1nstructions1111111111111111111111111") // The RecentBlockhashes sysvar contains the active recent blockhashes as well as their associated fee calculators. // It is updated every slot. // Entries are ordered by descending block height, // so the first entry holds the most recent block hash, // and the last entry holds an old block hash. SysVarRecentBlockHashesPubkey = MustPublicKeyFromBase58("SysvarRecentB1ockHashes11111111111111111111") // The Rent sysvar contains the rental rate. // Currently, the rate is static and set in genesis. // The Rent burn percentage is modified by manual feature activation. SysVarRentPubkey = MustPublicKeyFromBase58("SysvarRent111111111111111111111111111111111") // SysVarRewardsPubkey = MustPublicKeyFromBase58("SysvarRewards111111111111111111111111111111") // The SlotHashes sysvar contains the most recent hashes of the slot's parent banks. // It is updated every slot. SysVarSlotHashesPubkey = MustPublicKeyFromBase58("SysvarS1otHashes111111111111111111111111111") // The SlotHistory sysvar contains a bitvector of slots present over the last epoch. It is updated every slot. SysVarSlotHistoryPubkey = MustPublicKeyFromBase58("SysvarS1otHistory11111111111111111111111111") // The StakeHistory sysvar contains the history of cluster-wide stake activations and de-activations per epoch. // It is updated at the start of every epoch. SysVarStakeHistoryPubkey = MustPublicKeyFromBase58("SysvarStakeHistory1111111111111111111111111") )
var ErrInstructionDecoderNotFound = errors.New("instruction decoder not found")
var ErrMaxSeedLengthExceeded = errors.New("Max seed length exceeded")
var (
TokenMetadataProgramID = MustPublicKeyFromBase58("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
)
Functions ¶
func DecimalsInBigInt ¶
func DecodeInstruction ¶
func DecodeInstruction(programID PublicKey, accounts []*AccountMeta, data []byte) (interface{}, error)
func GetAddedRemovedPubkeys ¶
func GetAddedRemovedPubkeys(previous PublicKeySlice, next PublicKeySlice) (added PublicKeySlice, removed PublicKeySlice)
GetAddedRemovedPubkeys accepts two slices of pubkeys (`previous` and `next`), and returns two slices: - `added` is the slice of pubkeys that are present in `next` but NOT present in `previous`. - `removed` is the slice of pubkeys that are present in `previous` but are NOT present in `next`.
func IsAnyOfEncodingType ¶
func IsAnyOfEncodingType(candidate EncodingType, allowed ...EncodingType) bool
IsAnyOfEncodingType checks whether the provided `candidate` is any of the `allowed`.
func RegisterInstructionDecoder ¶
func RegisterInstructionDecoder(programID PublicKey, decoder InstructionDecoder)
Types ¶
type AccountMeta ¶
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) 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() []*AccountMeta
func (AccountMetaSlice) GetKeys ¶
func (slice AccountMetaSlice) GetKeys() PublicKeySlice
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
func (AccountMetaSlice) SplitFrom ¶
func (slice AccountMetaSlice) SplitFrom(index int) (AccountMetaSlice, AccountMetaSlice)
type AccountsGettable ¶
type AccountsGettable interface {
GetAccounts() (accounts []*AccountMeta)
}
type AccountsSettable ¶
type AccountsSettable interface {
SetAccounts(accounts []*AccountMeta) error
}
type ByteWrapper ¶
func (*ByteWrapper) ReadByte ¶
func (w *ByteWrapper) ReadByte() (byte, error)
type CompiledInstruction ¶
type CompiledInstruction struct { // 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 Base58 `json:"data"` }
func (*CompiledInstruction) ResolveInstructionAccounts ¶
func (ci *CompiledInstruction) ResolveInstructionAccounts(message *Message) ([]*AccountMeta, error)
type Data ¶
type Data struct { Content []byte Encoding EncodingType }
func (Data) MarshalJSON ¶
func (Data) MarshalWithEncoder ¶
func (*Data) UnmarshalJSON ¶
type DurationMilliseconds ¶
type DurationMilliseconds int64
DurationMilliseconds represents a duration in milliseconds.
func (DurationMilliseconds) Duration ¶
func (res DurationMilliseconds) Duration() time.Duration
func (DurationMilliseconds) String ¶
func (res DurationMilliseconds) String() string
type DurationSeconds ¶
type DurationSeconds int64
DurationSeconds represents a duration in seconds.
func (DurationSeconds) Duration ¶
func (res DurationSeconds) Duration() time.Duration
func (DurationSeconds) String ¶
func (res DurationSeconds) String() string
type EncodingType ¶
type EncodingType string
const ( EncodingBase58 EncodingType = "base58" // limited to Account data of less than 129 bytes EncodingBase64 EncodingType = "base64" // will return base64 encoded data for Account data of any size EncodingBase64Zstd EncodingType = "base64+zstd" // compresses the Account data using Zstandard and base64-encodes the result // attempts to use program-specific state parsers to // return more human-readable and explicit account state data. // If "jsonParsed" is requested but a parser cannot be found, // the field falls back to "base64" encoding, detectable when the data field is type <string>. // Cannot be used if specifying dataSlice parameters (offset, length). EncodingJSONParsed EncodingType = "jsonParsed" EncodingJSON EncodingType = "json" // NOTE: you're probably looking for EncodingJSONParsed )
type GenericInstruction ¶
type GenericInstruction struct { AccountValues AccountMetaSlice ProgID PublicKey DataBytes []byte }
func NewInstruction ¶
func NewInstruction( programID PublicKey, accounts AccountMetaSlice, data []byte, ) *GenericInstruction
NewInstruction creates a generic instruction with the provided programID, accounts, and data bytes.
func (*GenericInstruction) Accounts ¶
func (in *GenericInstruction) Accounts() []*AccountMeta
func (*GenericInstruction) Data ¶
func (in *GenericInstruction) Data() ([]byte, error)
func (*GenericInstruction) ProgramID ¶
func (in *GenericInstruction) ProgramID() PublicKey
type Hash ¶
type Hash PublicKey
func HashFromBase58 ¶
HashFromBase58 decodes a base58 string into a Hash.
func HashFromBytes ¶
HashFromBytes decodes a byte slice into a Hash.
func MustHashFromBase58 ¶
MustHashFromBase58 decodes a base58 string into a Hash. Panics on error.
func (Hash) MarshalJSON ¶
func (Hash) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Hash) UnmarshalJSON ¶
func (*Hash) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
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 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 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"` // static keys; static keys + dynamic keys if after resolution (i.e. call to `ResolveLookups()`) // 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) AccountMetaList ¶
func (m Message) AccountMetaList() (AccountMetaSlice, error)
func (*Message) AddAddressTableLookup ¶
func (mx *Message) AddAddressTableLookup(lookup MessageAddressTableLookup) *Message
AddAddressTableLookup adds a new lookup to the message.
func (*Message) EncodeToTree ¶
func (Message) GetAddressTableLookupAccounts ¶
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) GetAddressTableLookups ¶
func (mx *Message) GetAddressTableLookups() MessageAddressTableLookupSlice
GetAddressTableLookups returns the lookups used by this message.
func (*Message) GetAddressTables ¶
func (mx *Message) GetAddressTables() map[PublicKey]PublicKeySlice
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 ¶
func (mx Message) GetAllKeys() (keys PublicKeySlice, err error)
GetAllKeys returns ALL the message's account keys (including the keys from resolved address lookup tables).
func (*Message) GetVersion ¶
func (m *Message) GetVersion() MessageVersion
GetVersion returns the message version.
func (Message) IsVersioned ¶
func (*Message) MarshalBinary ¶
func (Message) MarshalJSON ¶
func (*Message) MarshalLegacy ¶
func (Message) MarshalWithEncoder ¶
func (Message) NumLookups ¶
func (Message) NumWritableLookups ¶
func (*Message) ResolveLookups ¶
ResolveLookups resolves the address table lookups, and appends the resolved accounts to the `message.AccountKeys` field. NOTE: you need to call `SetAddressTables` before calling this method.
func (Message) ResolveProgramIDIndex ¶
ResolveProgramIDIndex resolves the program ID index to a program ID. DEPRECATED: use `Program(index)` instead.
func (*Message) SetAddressTableLookups ¶
func (mx *Message) SetAddressTableLookups(lookups []MessageAddressTableLookup) *Message
SetAddressTableLookups (re)sets the lookups used by this message.
func (*Message) SetAddressTables ¶
func (mx *Message) SetAddressTables(tables map[PublicKey]PublicKeySlice) 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) SetVersion ¶
func (m *Message) SetVersion(version MessageVersion) *Message
SetVersion sets the message version. This method forces the message to be encoded in the specified version. NOTE: if you set lookups, the version will default to V0.
func (Message) Signers ¶
func (m Message) Signers() PublicKeySlice
Signers returns the pubkeys of all accounts that are signers.
func (*Message) UnmarshalBase64 ¶
func (*Message) UnmarshalLegacy ¶
func (*Message) UnmarshalWithDecoder ¶
func (Message) Writable ¶
func (m Message) Writable() (out PublicKeySlice, err error)
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 Uint8SliceAsNum `json:"writableIndexes"` ReadonlyIndexes Uint8SliceAsNum `json:"readonlyIndexes"` }
type MessageAddressTableLookupSlice ¶
type MessageAddressTableLookupSlice []MessageAddressTableLookup
func (MessageAddressTableLookupSlice) GetTableIDs ¶
func (lookups MessageAddressTableLookupSlice) GetTableIDs() PublicKeySlice
GetTableIDs returns the list of all address table IDs.
func (MessageAddressTableLookupSlice) NumLookups ¶
func (lookups MessageAddressTableLookupSlice) NumLookups() int
NumLookups returns the number of accounts from all the lookups.
func (MessageAddressTableLookupSlice) NumWritableLookups ¶
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"` }
func (*MessageHeader) EncodeToTree ¶
func (header *MessageHeader) EncodeToTree(mxBranch treeout.Branches)
type MessageVersion ¶
type MessageVersion int
const ( MessageVersionLegacy MessageVersion = 0 // default MessageVersionV0 MessageVersion = 1 // v0 )
type PrivateKey ¶
type PrivateKey []byte
func MustPrivateKeyFromBase58 ¶
func MustPrivateKeyFromBase58(in string) PrivateKey
func NewRandomPrivateKey ¶
func NewRandomPrivateKey() (PrivateKey, error)
func PrivateKeyFromBase58 ¶
func PrivateKeyFromBase58(privkey string) (PrivateKey, error)
func PrivateKeyFromSolanaKeygenFile ¶
func PrivateKeyFromSolanaKeygenFile(file string) (PrivateKey, error)
func (PrivateKey) PublicKey ¶
func (k PrivateKey) PublicKey() PublicKey
func (PrivateKey) String ¶
func (k PrivateKey) String() string
type PublicKey ¶
type PublicKey [PublicKeyLength]byte
func CreateProgramAddress ¶
Create a program address. Ported from https://github.com/solana-labs/solana/blob/216983c50e0a618facc39aa07472ba6d23f1b33a/sdk/program/src/pubkey.rs#L204
func CreateWithSeed ¶
func FindProgramAddress ¶
Find a valid program address and its corresponding bump seed.
func FindTokenMetadataAddress ¶
FindTokenMetadataAddress returns the token metadata program-derived address given a SPL token mint address.
func MustPublicKeyFromBase58 ¶
func PublicKeyFromBase58 ¶
func PublicKeyFromBytes ¶
func (PublicKey) IsZero ¶
IsZero returns whether the public key is zero. NOTE: the System Program public key is also zero.
func (PublicKey) MarshalBSON ¶
MarshalBSON implements the bson.Marshaler interface.
func (PublicKey) MarshalBSONValue ¶
MarshalBSONValue implements the bson.ValueMarshaler interface.
func (PublicKey) MarshalJSON ¶
func (PublicKey) MarshalText ¶
func (PublicKey) Short ¶
Short returns a shortened pubkey string, only including the first n chars, ellipsis, and the last n characters. NOTE: this is ONLY for visual representation for humans, and cannot be used for anything else.
func (*PublicKey) UnmarshalBSON ¶
UnmarshalBSON implements the bson.Unmarshaler interface.
func (*PublicKey) UnmarshalBSONValue ¶
UnmarshalBSONValue implements the bson.ValueUnmarshaler interface.
func (*PublicKey) UnmarshalJSON ¶
func (*PublicKey) UnmarshalText ¶
type PublicKeySlice ¶
type PublicKeySlice []PublicKey
func (PublicKeySlice) Added ¶
func (a PublicKeySlice) Added(b PublicKeySlice) PublicKeySlice
Added returns the elements that are present in `b` but not in `a`.
func (*PublicKeySlice) Append ¶
func (slice *PublicKeySlice) Append(pubkeys ...PublicKey)
func (PublicKeySlice) Contains ¶
func (slice PublicKeySlice) Contains(pubkey PublicKey) bool
Contains returns true if the slice contains the provided pubkey.
func (PublicKeySlice) ContainsAll ¶
func (slice PublicKeySlice) ContainsAll(pubkeys PublicKeySlice) bool
ContainsAll returns true if all the provided pubkeys are present in the slice.
func (PublicKeySlice) ContainsAny ¶
func (slice PublicKeySlice) ContainsAny(pubkeys PublicKeySlice) bool
ContainsAny returns true if any of the provided pubkeys are present in the slice.
func (PublicKeySlice) Dedupe ¶
func (slice PublicKeySlice) Dedupe() PublicKeySlice
Dedupe returns a new slice with all duplicate pubkeys removed.
func (PublicKeySlice) Equals ¶
func (slice PublicKeySlice) Equals(other PublicKeySlice) bool
Equals returns true if the two PublicKeySlices are equal (same order of same keys).
func (PublicKeySlice) First ¶
func (slice PublicKeySlice) First() *PublicKey
First returns the first element of the slice. Returns nil if the slice is empty.
func (PublicKeySlice) GetAddedRemoved ¶
func (prev PublicKeySlice) GetAddedRemoved(next PublicKeySlice) (added PublicKeySlice, removed PublicKeySlice)
GetAddedRemoved compares to the `next` pubkey slice, and returns two slices: - `added` is the slice of pubkeys that are present in `next` but NOT present in `previous`. - `removed` is the slice of pubkeys that are present in `previous` but are NOT present in `next`.
func (PublicKeySlice) Has ¶
func (slice PublicKeySlice) Has(pubkey PublicKey) bool
func (PublicKeySlice) Intersect ¶
func (prev PublicKeySlice) Intersect(next PublicKeySlice) PublicKeySlice
Intersect returns the intersection of two PublicKeySlices, i.e. the elements that are in both PublicKeySlices. The returned PublicKeySlice is sorted and deduped.
func (PublicKeySlice) Last ¶
func (slice PublicKeySlice) Last() *PublicKey
Last returns the last element of the slice. Returns nil if the slice is empty.
func (PublicKeySlice) Len ¶
func (slice PublicKeySlice) Len() int
func (PublicKeySlice) Less ¶
func (slice PublicKeySlice) Less(i, j int) bool
func (PublicKeySlice) Removed ¶
func (a PublicKeySlice) Removed(b PublicKeySlice) PublicKeySlice
Removed returns the elements that are present in `a` but not in `b`.
func (PublicKeySlice) Same ¶
func (slice PublicKeySlice) Same(other PublicKeySlice) bool
Same returns true if the two slices contain the same public keys, but not necessarily in the same order.
func (PublicKeySlice) Split ¶
func (slice PublicKeySlice) Split(chunkSize int) []PublicKeySlice
Split splits the slice into chunks of the specified size.
func (PublicKeySlice) Swap ¶
func (slice PublicKeySlice) Swap(i, j int)
func (PublicKeySlice) ToBase58 ¶
func (slice PublicKeySlice) ToBase58() []string
func (PublicKeySlice) ToBytes ¶
func (slice PublicKeySlice) ToBytes() [][]byte
func (PublicKeySlice) ToPointers ¶
func (slice PublicKeySlice) ToPointers() []*PublicKey
func (*PublicKeySlice) UniqueAppend ¶
func (slice *PublicKeySlice) UniqueAppend(pubkey PublicKey) bool
UniqueAppend appends the provided pubkey only if it is not already present in the slice. Returns true when the provided pubkey wasn't already present.
type Signature ¶
type Signature [64]byte
func MustSignatureFromBase58 ¶
MustSignatureFromBase58 decodes a base58 string into a Signature. Panics on error.
func SignatureFromBase58 ¶
SignatureFromBase58 decodes a base58 string into a Signature.
func SignatureFromBytes ¶
SignatureFromBytes decodes a byte slice into a Signature.
func (Signature) MarshalJSON ¶
func (Signature) MarshalText ¶
func (*Signature) UnmarshalJSON ¶
func (*Signature) UnmarshalText ¶
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 MustTransactionFromDecoder ¶
func MustTransactionFromDecoder(decoder *bin.Decoder) *Transaction
MustTransactionFromDecoder decodes a transaction from a decoder. Panics on error.
func NewTransaction ¶
func NewTransaction(instructions []Instruction, recentBlockHash Hash, opts ...TransactionOption) (*Transaction, error)
func TransactionFromDecoder ¶
func TransactionFromDecoder(decoder *bin.Decoder) (*Transaction, error)
TransactionFromDecoder decodes a transaction from a decoder.
func (*Transaction) AccountMetaList ¶
func (t *Transaction) AccountMetaList() ([]*AccountMeta, error)
func (*Transaction) EncodeToTree ¶
func (tx *Transaction) EncodeToTree(parent treeout.Branches)
func (*Transaction) EncodeTree ¶
func (tx *Transaction) EncodeTree(encoder *text.TreeEncoder) (int, error)
func (*Transaction) HasAccount ¶
func (t *Transaction) HasAccount(account PublicKey) (bool, error)
func (*Transaction) IsSigner ¶
func (t *Transaction) IsSigner(account PublicKey) bool
func (*Transaction) IsWritable ¶
func (t *Transaction) IsWritable(account PublicKey) (bool, error)
func (*Transaction) MarshalBinary ¶
func (tx *Transaction) MarshalBinary() ([]byte, error)
func (Transaction) MarshalWithEncoder ¶
func (tx Transaction) MarshalWithEncoder(encoder *bin.Encoder) error
func (Transaction) MustToBase64 ¶
func (tx Transaction) MustToBase64() string
func (*Transaction) PartialSign ¶
func (tx *Transaction) PartialSign(getter privateKeyGetter) (out []Signature, err error)
func (*Transaction) ResolveProgramIDIndex ¶
func (t *Transaction) ResolveProgramIDIndex(programIDIndex uint16) (PublicKey, error)
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
func (*Transaction) String ¶
func (tx *Transaction) String() string
String returns a human-readable string representation of the transaction data. To disable colors, set "github.com/stonecoldik/go-solana/text".DisableColors = true
func (Transaction) ToBase64 ¶
func (tx Transaction) ToBase64() (string, error)
func (*Transaction) UnmarshalBase64 ¶
func (tx *Transaction) UnmarshalBase64(b64 string) error
UnmarshalBase64 decodes a base64 encoded transaction.
func (*Transaction) UnmarshalWithDecoder ¶
func (tx *Transaction) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)
func (*Transaction) VerifySignatures ¶
func (tx *Transaction) VerifySignatures() error
VerifySignatures verifies all the signatures in the transaction against the pubkeys of the signers.
type TransactionBuilder ¶
type TransactionBuilder struct {
// contains filtered or unexported fields
}
func NewTransactionBuilder ¶
func NewTransactionBuilder() *TransactionBuilder
NewTransactionBuilder creates a new instruction builder.
func (*TransactionBuilder) AddInstruction ¶
func (builder *TransactionBuilder) AddInstruction(instruction Instruction) *TransactionBuilder
AddInstruction adds the provided instruction to the builder.
func (*TransactionBuilder) Build ¶
func (builder *TransactionBuilder) Build() (*Transaction, error)
Build builds and returns a *Transaction.
func (*TransactionBuilder) SetFeePayer ¶
func (builder *TransactionBuilder) SetFeePayer(feePayer PublicKey) *TransactionBuilder
Set transaction fee payer. If not set, defaults to first signer account of the first instruction.
func (*TransactionBuilder) SetRecentBlockHash ¶
func (builder *TransactionBuilder) SetRecentBlockHash(recentBlockHash Hash) *TransactionBuilder
SetRecentBlockHash sets the recent blockhash for the instruction builder.
func (*TransactionBuilder) WithOpt ¶
func (builder *TransactionBuilder) WithOpt(opt TransactionOption) *TransactionBuilder
WithOpt adds a TransactionOption.
type TransactionOption ¶
type TransactionOption interface {
// contains filtered or unexported methods
}
func TransactionAddressTables ¶
func TransactionAddressTables(tables map[PublicKey]PublicKeySlice) TransactionOption
func TransactionPayer ¶
func TransactionPayer(payer PublicKey) TransactionOption
type Uint8SliceAsNum ¶
type Uint8SliceAsNum []uint8
Uint8SliceAsNum is a slice of uint8s that can be marshaled as numbers instead of a byte slice.
func (Uint8SliceAsNum) MarshalJSON ¶
func (slice Uint8SliceAsNum) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
type UnixTimeMilliseconds ¶
type UnixTimeMilliseconds int64
UnixTimeMilliseconds represents a UNIX millisecond-resolution timestamp.
func (UnixTimeMilliseconds) String ¶
func (res UnixTimeMilliseconds) String() string
func (UnixTimeMilliseconds) Time ¶
func (res UnixTimeMilliseconds) Time() time.Time
type UnixTimeSeconds ¶
type UnixTimeSeconds int64
UnixTimeSeconds represents a UNIX second-resolution timestamp.
func (UnixTimeSeconds) String ¶
func (res UnixTimeSeconds) String() string
func (UnixTimeSeconds) Time ¶
func (res UnixTimeSeconds) Time() time.Time
type Wallet ¶
type Wallet struct {
PrivateKey PrivateKey
}
Wallet is a wrapper around a PrivateKey
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
programs
|
|
serum
Code generated by rice embed-go; DO NOT EDIT.
|
Code generated by rice embed-go; DO NOT EDIT. |
jsonrpc
Package jsonrpc provides a JSON-RPC 2.0 client that sends JSON-RPC requests and receives JSON-RPC responses using HTTP.
|
Package jsonrpc provides a JSON-RPC 2.0 client that sends JSON-RPC requests and receives JSON-RPC responses using HTTP. |