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) AccountMetaList() AccountMetaSlice
- func (mx *Message) AddAddressTableLookup(lookup MessageAddressTableLookup) *Message
- func (mx *Message) EncodeToTree(txTree treeout.Branches)
- func (mx *Message) GetAddressTableLookups() MessageAddressTableLookupSlice
- func (mx *Message) GetAddressTables() map[PublicKey][]PublicKey
- func (m *Message) GetVersion() MessageVersion
- func (m Message) HasAccount(account PublicKey) bool
- func (m Message) IsSigner(account PublicKey) bool
- func (m Message) IsVersioned() bool
- func (m Message) IsWritable(account PublicKey) bool
- func (mx *Message) MarshalBinary() ([]byte, error)
- func (mx *Message) MarshalLegacy() ([]byte, error)
- func (mx *Message) MarshalV0() ([]byte, error)
- func (mx Message) MarshalWithEncoder(encoder *bin.Encoder) error
- func (m Message) ResolveProgramIDIndex(programIDIndex uint16) (PublicKey, error)
- func (mx *Message) SetAddressTableLookups(lookups []MessageAddressTableLookup) *Message
- func (mx *Message) SetAddressTables(tables map[PublicKey][]PublicKey) 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)
- 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) IsOnCurve() bool
- func (p PublicKey) IsZero() bool
- 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) 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() (out []*AccountMeta)
- func (tx *Transaction) EncodeToTree(parent treeout.Branches)
- func (tx *Transaction) EncodeTree(encoder *text.TreeEncoder) (int, error)
- func (t *Transaction) HasAccount(account PublicKey) bool
- func (t *Transaction) IsSigner(account PublicKey) bool
- func (t *Transaction) IsWritable(account PublicKey) bool
- 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 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 ¶ added in v1.1.0
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 ¶ added in v0.3.5
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 ¶ added in v0.4.0
func Meta( pubKey PublicKey, ) *AccountMeta
Meta intializes a new AccountMeta with the provided pubKey.
func NewAccountMeta ¶ added in v0.4.0
func NewAccountMeta( pubKey PublicKey, WRITE bool, SIGNER bool, ) *AccountMeta
func (*AccountMeta) SIGNER ¶ added in v0.4.0
func (meta *AccountMeta) SIGNER() *AccountMeta
SIGNER sets IsSigner to true.
func (*AccountMeta) WRITE ¶ added in v0.4.0
func (meta *AccountMeta) WRITE() *AccountMeta
WRITE sets IsWritable to true.
type AccountMetaSlice ¶ added in v0.4.0
type AccountMetaSlice []*AccountMeta
func (*AccountMetaSlice) Append ¶ added in v0.4.0
func (slice *AccountMetaSlice) Append(account *AccountMeta)
func (AccountMetaSlice) Get ¶ added in v1.1.0
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 ¶ added in v0.4.0
func (slice AccountMetaSlice) GetAccounts() []*AccountMeta
func (AccountMetaSlice) GetKeys ¶ added in v1.2.0
func (slice AccountMetaSlice) GetKeys() PublicKeySlice
GetKeys returns the pubkeys of all AccountMeta.
func (AccountMetaSlice) GetSigners ¶ added in v0.4.0
func (slice AccountMetaSlice) GetSigners() []*AccountMeta
GetSigners returns the accounts that are signers.
func (AccountMetaSlice) Len ¶ added in v0.4.4
func (slice AccountMetaSlice) Len() int
func (*AccountMetaSlice) SetAccounts ¶ added in v0.4.0
func (slice *AccountMetaSlice) SetAccounts(accounts []*AccountMeta) error
func (AccountMetaSlice) SplitFrom ¶ added in v0.4.4
func (slice AccountMetaSlice) SplitFrom(index int) (AccountMetaSlice, AccountMetaSlice)
type AccountsGettable ¶ added in v0.4.0
type AccountsGettable interface {
GetAccounts() (accounts []*AccountMeta)
}
type AccountsSettable ¶ added in v0.4.0
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
type Data ¶
type Data struct { Content []byte Encoding EncodingType }
func (Data) MarshalJSON ¶
func (Data) MarshalWithEncoder ¶ added in v1.2.0
func (*Data) UnmarshalJSON ¶
type DurationMilliseconds ¶ added in v1.7.0
type DurationMilliseconds int64
DurationMilliseconds represents a duration in milliseconds.
func (DurationMilliseconds) Duration ¶ added in v1.7.0
func (res DurationMilliseconds) Duration() time.Duration
func (DurationMilliseconds) String ¶ added in v1.7.0
func (res DurationMilliseconds) String() string
type DurationSeconds ¶ added in v1.0.1
type DurationSeconds int64
DurationSeconds represents a duration in seconds.
func (DurationSeconds) Duration ¶ added in v1.0.1
func (res DurationSeconds) Duration() time.Duration
func (DurationSeconds) String ¶ added in v1.0.1
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 ¶ added in v0.5.0
type GenericInstruction struct { AccountValues AccountMetaSlice ProgID PublicKey DataBytes []byte }
func NewInstruction ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (in *GenericInstruction) Accounts() []*AccountMeta
func (*GenericInstruction) Data ¶ added in v0.5.0
func (in *GenericInstruction) Data() ([]byte, error)
func (*GenericInstruction) ProgramID ¶ added in v0.5.0
func (in *GenericInstruction) ProgramID() PublicKey
type Hash ¶
type Hash PublicKey
func HashFromBase58 ¶
HashFromBase58 decodes a base58 string into a Hash.
func HashFromBytes ¶ added in v1.0.2
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 ¶ added in v1.6.0
MarshalText implements encoding.TextMarshaler.
func (*Hash) UnmarshalJSON ¶
func (*Hash) UnmarshalText ¶ added in v1.6.0
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"` // 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"` // contains filtered or unexported fields }
func (Message) AccountMetaList ¶
func (m Message) AccountMetaList() AccountMetaSlice
func (*Message) AddAddressTableLookup ¶ added in v1.7.0
func (mx *Message) AddAddressTableLookup(lookup MessageAddressTableLookup) *Message
func (*Message) EncodeToTree ¶ added in v0.4.0
func (*Message) GetAddressTableLookups ¶ added in v1.7.0
func (mx *Message) GetAddressTableLookups() MessageAddressTableLookupSlice
func (*Message) GetAddressTables ¶ added in v1.7.0
GetAddressTables returns the address tables used by this message. NOTE: you must have called `SetAddressTable` one or more times before being able to use this method.
func (*Message) GetVersion ¶ added in v1.7.0
func (m *Message) GetVersion() MessageVersion
GetVersion returns the message version.
func (Message) HasAccount ¶ added in v1.2.0
func (Message) IsVersioned ¶ added in v1.7.0
func (Message) IsWritable ¶
func (*Message) MarshalBinary ¶ added in v0.3.5
func (*Message) MarshalLegacy ¶ added in v1.7.0
func (Message) MarshalWithEncoder ¶ added in v0.4.0
func (Message) ResolveProgramIDIndex ¶
func (*Message) SetAddressTableLookups ¶ added in v1.7.0
func (mx *Message) SetAddressTableLookups(lookups []MessageAddressTableLookup) *Message
func (*Message) SetAddressTables ¶ added in v1.7.0
func (*Message) SetVersion ¶ added in v1.7.0
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 ¶ added in v1.2.0
func (m Message) Signers() PublicKeySlice
Signers returns the pubkeys of all accounts that are signers.
func (*Message) UnmarshalBase64 ¶ added in v1.7.0
func (*Message) UnmarshalLegacy ¶ added in v1.7.0
func (*Message) UnmarshalV0 ¶ added in v1.7.0
func (*Message) UnmarshalWithDecoder ¶ added in v0.4.0
func (Message) Writable ¶ added in v1.2.0
func (m Message) Writable() (out PublicKeySlice)
Writable returns the pubkeys of all accounts that are writable.
type MessageAddressTableLookup ¶ added in v1.7.0
type MessageAddressTableLookupSlice ¶ added in v1.7.0
type MessageAddressTableLookupSlice []MessageAddressTableLookup
func (MessageAddressTableLookupSlice) GetTableIDs ¶ added in v1.7.0
func (lookups MessageAddressTableLookupSlice) GetTableIDs() PublicKeySlice
GetTableIDs returns the list of all address table IDs.
func (MessageAddressTableLookupSlice) NumLookups ¶ added in v1.7.0
func (lookups MessageAddressTableLookupSlice) NumLookups() int
NumLookups returns the number of accounts in all the MessageAddressTableLookupSlice
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 ¶ added in v0.4.0
func (header *MessageHeader) EncodeToTree(mxBranch treeout.Branches)
type MessageVersion ¶ added in v1.7.0
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 ¶ added in v0.4.0
Create a program address. Ported from https://github.com/solana-labs/solana/blob/216983c50e0a618facc39aa07472ba6d23f1b33a/sdk/program/src/pubkey.rs#L204
func CreateWithSeed ¶ added in v0.4.0
func FindAssociatedTokenAddress ¶ added in v0.4.0
func FindProgramAddress ¶ added in v0.4.0
Find a valid program address and its corresponding bump seed.
func FindTokenMetadataAddress ¶ added in v1.0.2
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) MarshalJSON ¶
func (PublicKey) MarshalText ¶ added in v0.3.4
func (PublicKey) Short ¶ added in v1.1.0
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) UnmarshalJSON ¶
func (*PublicKey) UnmarshalText ¶ added in v0.3.4
type PublicKeySlice ¶ added in v0.4.0
type PublicKeySlice []PublicKey
func (PublicKeySlice) Added ¶ added in v1.7.0
func (a PublicKeySlice) Added(b PublicKeySlice) PublicKeySlice
Added returns the elements that are present in `b` but not in `a`.
func (*PublicKeySlice) Append ¶ added in v0.4.0
func (slice *PublicKeySlice) Append(pubkeys ...PublicKey)
func (PublicKeySlice) Contains ¶ added in v1.7.0
func (slice PublicKeySlice) Contains(pubkey PublicKey) bool
Contains returns true if the slice contains the provided pubkey.
func (PublicKeySlice) ContainsAll ¶ added in v1.7.0
func (slice PublicKeySlice) ContainsAll(pubkeys PublicKeySlice) bool
ContainsAll returns true if all the provided pubkeys are present in the slice.
func (PublicKeySlice) ContainsAny ¶ added in v1.7.0
func (slice PublicKeySlice) ContainsAny(pubkeys PublicKeySlice) bool
ContainsAny returns true if any of the provided pubkeys are present in the slice.
func (PublicKeySlice) Dedupe ¶ added in v1.7.0
func (slice PublicKeySlice) Dedupe() PublicKeySlice
Dedupe returns a new slice with all duplicate pubkeys removed.
func (PublicKeySlice) Equals ¶ added in v1.7.0
func (slice PublicKeySlice) Equals(other PublicKeySlice) bool
Equals returns true if the two PublicKeySlices are equal (same order of same keys).
func (PublicKeySlice) First ¶ added in v1.7.0
func (slice PublicKeySlice) First() *PublicKey
First returns the first element of the slice. Returns nil if the slice is empty.
func (PublicKeySlice) GetAddedRemoved ¶ added in v1.7.0
func (prev PublicKeySlice) GetAddedRemoved(next PublicKeySlice) (added PublicKeySlice, removed PublicKeySlice)
func (PublicKeySlice) Has ¶ added in v0.4.0
func (slice PublicKeySlice) Has(pubkey PublicKey) bool
func (PublicKeySlice) Intersect ¶ added in v1.7.0
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 ¶ added in v1.7.0
func (slice PublicKeySlice) Last() *PublicKey
Last returns the last element of the slice. Returns nil if the slice is empty.
func (PublicKeySlice) Len ¶ added in v1.7.0
func (slice PublicKeySlice) Len() int
func (PublicKeySlice) Less ¶ added in v1.7.0
func (slice PublicKeySlice) Less(i, j int) bool
func (PublicKeySlice) Removed ¶ added in v1.7.0
func (a PublicKeySlice) Removed(b PublicKeySlice) PublicKeySlice
Removed returns the elements that are present in `a` but not in `b`.
func (PublicKeySlice) Same ¶ added in v1.7.0
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) Sort ¶ added in v1.7.0
func (slice PublicKeySlice) Sort()
Sort sorts the slice.
func (PublicKeySlice) Split ¶ added in v1.1.0
func (slice PublicKeySlice) Split(chunkSize int) []PublicKeySlice
Split splits the slice into chunks of the specified size.
func (PublicKeySlice) Swap ¶ added in v1.7.0
func (slice PublicKeySlice) Swap(i, j int)
func (PublicKeySlice) ToBase58 ¶ added in v1.7.0
func (slice PublicKeySlice) ToBase58() []string
func (PublicKeySlice) ToBytes ¶ added in v1.7.0
func (slice PublicKeySlice) ToBytes() [][]byte
func (PublicKeySlice) ToPointers ¶ added in v1.7.0
func (slice PublicKeySlice) ToPointers() []*PublicKey
func (*PublicKeySlice) UniqueAppend ¶ added in v0.4.0
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 ¶ added in v1.2.0
SignatureFromBytes decodes a byte slice into a Signature.
func (Signature) MarshalJSON ¶
func (Signature) MarshalText ¶ added in v1.6.0
func (*Signature) UnmarshalJSON ¶
func (*Signature) UnmarshalText ¶ added in v1.6.0
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 ¶ added in v0.4.1
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 ¶ added in v0.4.0
func TransactionFromDecoder(decoder *bin.Decoder) (*Transaction, error)
TransactionFromDecoder decodes a transaction from a decoder.
func (*Transaction) AccountMetaList ¶
func (t *Transaction) AccountMetaList() (out []*AccountMeta)
func (*Transaction) EncodeToTree ¶ added in v0.4.0
func (tx *Transaction) EncodeToTree(parent treeout.Branches)
func (*Transaction) EncodeTree ¶ added in v0.4.0
func (tx *Transaction) EncodeTree(encoder *text.TreeEncoder) (int, error)
func (*Transaction) HasAccount ¶ added in v1.2.0
func (t *Transaction) HasAccount(account PublicKey) bool
func (*Transaction) IsSigner ¶
func (t *Transaction) IsSigner(account PublicKey) bool
func (*Transaction) IsWritable ¶
func (t *Transaction) IsWritable(account PublicKey) bool
func (*Transaction) MarshalBinary ¶ added in v0.3.5
func (tx *Transaction) MarshalBinary() ([]byte, error)
func (Transaction) MarshalWithEncoder ¶ added in v0.4.0
func (tx Transaction) MarshalWithEncoder(encoder *bin.Encoder) error
func (Transaction) MustToBase64 ¶ added in v1.3.0
func (tx Transaction) MustToBase64() string
func (*Transaction) PartialSign ¶ added in v1.7.0
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 ¶ added in v1.2.0
func (tx *Transaction) String() string
String returns a human-readable string representation of the transaction data. To disable colors, set "github.com/gagliardetto/solana-go/text".DisableColors = true
func (Transaction) ToBase64 ¶ added in v1.3.0
func (tx Transaction) ToBase64() (string, error)
func (*Transaction) UnmarshalBase64 ¶ added in v1.7.0
func (tx *Transaction) UnmarshalBase64(b64 string) error
UnmarshalBase64 decodes a base64 encoded transaction.
func (*Transaction) UnmarshalWithDecoder ¶ added in v0.4.0
func (tx *Transaction) UnmarshalWithDecoder(decoder *bin.Decoder) (err error)
func (*Transaction) VerifySignatures ¶ added in v1.2.0
func (tx *Transaction) VerifySignatures() error
VerifySignatures verifies all the signatures in the transaction against the pubkeys of the signers.
type TransactionBuilder ¶ added in v0.4.0
type TransactionBuilder struct {
// contains filtered or unexported fields
}
func NewTransactionBuilder ¶ added in v0.4.0
func NewTransactionBuilder() *TransactionBuilder
NewTransactionBuilder creates a new instruction builder.
func (*TransactionBuilder) AddInstruction ¶ added in v0.4.0
func (builder *TransactionBuilder) AddInstruction(instruction Instruction) *TransactionBuilder
AddInstruction adds the provided instruction to the builder.
func (*TransactionBuilder) Build ¶ added in v0.4.0
func (builder *TransactionBuilder) Build() (*Transaction, error)
Build builds and returns a *Transaction.
func (*TransactionBuilder) SetFeePayer ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (builder *TransactionBuilder) SetRecentBlockHash(recentBlockHash Hash) *TransactionBuilder
SetRecentBlockHash sets the recent blockhash for the instruction builder.
func (*TransactionBuilder) WithOpt ¶ added in v0.4.0
func (builder *TransactionBuilder) WithOpt(opt TransactionOption) *TransactionBuilder
WithOpt adds a TransactionOption.
type TransactionOption ¶
type TransactionOption interface {
// contains filtered or unexported methods
}
func TransactionPayer ¶
func TransactionPayer(payer PublicKey) TransactionOption
type UnixTimeMilliseconds ¶ added in v1.5.0
type UnixTimeMilliseconds int64
UnixTimeMilliseconds represents a UNIX millisecond-resolution timestamp.
func (UnixTimeMilliseconds) String ¶ added in v1.5.0
func (res UnixTimeMilliseconds) String() string
func (UnixTimeMilliseconds) Time ¶ added in v1.5.0
func (res UnixTimeMilliseconds) Time() time.Time
type UnixTimeSeconds ¶ added in v0.5.0
type UnixTimeSeconds int64
UnixTimeSeconds represents a UNIX second-resolution timestamp.
func (UnixTimeSeconds) String ¶ added in v0.5.1
func (res UnixTimeSeconds) String() string
func (UnixTimeSeconds) Time ¶ added in v0.5.0
func (res UnixTimeSeconds) Time() time.Time
type Wallet ¶ added in v0.4.2
type Wallet struct {
PrivateKey PrivateKey
}
Wallet is a wrapper around a PrivateKey
func WalletFromPrivateKeyBase58 ¶ added in v0.4.2
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. |