Documentation
¶
Overview ¶
Package addresslookuptable provides typed instruction builders for the Solana Address Lookup Table program. Address lookup tables are the mechanism v0 transactions use to reference accounts without consuming signature space: a single 32-byte lookup table address in the transaction header resolves to up to 256 accounts on-chain, letting programs like Jupiter and Whirlpool route through many more accounts than a legacy transaction would allow.
A typical lifecycle is:
- NewCreateLookupTable(authority, payer, recentSlot)
- NewExtendLookupTable(table, authority, payer, [addresses...]) (repeated, as many times as needed to fill the table)
- transactions reference the table via MessageAddressTableLookup
- NewFreezeLookupTable when the table is complete, to prevent further extends
- eventually NewDeactivateLookupTable + NewCloseLookupTable to reclaim rent
Index ¶
- Constants
- Variables
- func DeriveLookupTableAddress(authority solana.PublicKey, recentSlot uint64) (solana.PublicKey, uint8, error)
- func NewCloseLookupTable(lookupTable, authority, recipient solana.PublicKey) solana.Instruction
- func NewCreateLookupTable(authority, payer solana.PublicKey, recentSlot uint64) (solana.Instruction, solana.PublicKey, error)
- func NewDeactivateLookupTable(lookupTable, authority solana.PublicKey) solana.Instruction
- func NewExtendLookupTable(lookupTable, authority, payer solana.PublicKey, ...) solana.Instruction
- func NewFreezeLookupTable(lookupTable, authority solana.PublicKey) solana.Instruction
- type TableState
Constants ¶
const LookupTableMetaSize = 56
LookupTableMetaSize is the fixed byte length of the serialized LookupTableMeta header, matching the Solana runtime constant.
Variables ¶
var ProgramID = solana.MustPublicKey("AddressLookupTab1e1111111111111111111111111")
ProgramID is the canonical address of the Solana Address Lookup Table program.
Functions ¶
func DeriveLookupTableAddress ¶
func DeriveLookupTableAddress(authority solana.PublicKey, recentSlot uint64) (solana.PublicKey, uint8, error)
DeriveLookupTableAddress computes the program-derived address for a lookup table owned by authority at recentSlot. The PDA is the table's on-chain address; pass it back as the first account meta to every subsequent ALT instruction referring to this table.
The seed order is [authority, recentSlot as u64 LE bytes], matching the Solana runtime's derive_lookup_table_address.
func NewCloseLookupTable ¶
func NewCloseLookupTable(lookupTable, authority, recipient solana.PublicKey) solana.Instruction
NewCloseLookupTable builds an instruction that closes a deactivated lookup table and transfers its rent lamports to recipient. The table must be past the deactivation cooling-off period or the runtime will reject the call.
func NewCreateLookupTable ¶
func NewCreateLookupTable(authority, payer solana.PublicKey, recentSlot uint64) (solana.Instruction, solana.PublicKey, error)
NewCreateLookupTable builds an instruction that allocates a new address lookup table owned by authority. recentSlot must be a slot the runtime still considers "recent" — usually the current slot from client.GetSlot, or one of the last few.
The derived table address is returned alongside the instruction so callers can immediately reference it in subsequent extend / freeze calls. Both authority and payer must sign the transaction.
func NewDeactivateLookupTable ¶
func NewDeactivateLookupTable(lookupTable, authority solana.PublicKey) solana.Instruction
NewDeactivateLookupTable builds an instruction that marks a lookup table as deactivated. Deactivation does not immediately close the account; the table enters a cooling-off period (currently ~500 slots) during which it cannot be referenced by new transactions but its rent is still held.
func NewExtendLookupTable ¶
func NewExtendLookupTable(lookupTable, authority, payer solana.PublicKey, newAddresses []solana.PublicKey) solana.Instruction
NewExtendLookupTable builds an instruction that appends new addresses to a lookup table. Both authority and payer must sign; payer covers any additional rent required by the larger account.
A lookup table can hold up to 256 addresses total. Calling Extend when the table is already at the limit will fail.
func NewFreezeLookupTable ¶
func NewFreezeLookupTable(lookupTable, authority solana.PublicKey) solana.Instruction
NewFreezeLookupTable builds an instruction that freezes a lookup table, preventing any further extends. Only the table's authority can freeze it; freezing is permanent.
Types ¶
type TableState ¶
type TableState struct {
// DeactivationSlot is set to math.MaxUint64 (u64::MAX) while the table
// is active. Once NewDeactivateLookupTable is called it is set to the
// deactivation slot; the table cannot be closed until that slot is no
// longer recent.
DeactivationSlot uint64
// LastExtendedSlot is the slot during which the table was last extended.
LastExtendedSlot uint64
// LastExtendedSlotStartIndex is the first index added during the last
// extend operation.
LastExtendedSlotStartIndex uint8
// Authority is the account that may sign Extend, Freeze, Deactivate,
// and Close. Nil when the table has been frozen (permanently immutable).
Authority *solana.PublicKey
// Addresses is the ordered list of public keys stored in the table.
// Transactions reference entries by their 0-based index.
Addresses []solana.PublicKey
}
TableState holds the decoded on-chain state of an Address Lookup Table.
func DecodeTableState ¶
func DecodeTableState(data []byte) (*TableState, error)
DecodeTableState decodes the raw account data of an Address Lookup Table. The buffer must be at least LookupTableMetaSize (56) bytes.
Layout:
[0:4] discriminant u32 (must be 1 for LookupTable) [4:12] deactivation_slot u64 [12:20] last_extended_slot u64 [20] last_extended_slot_start_index u8 [21] authority tag u8 (0=None, 1=Some) [22:54] authority pubkey (32 B; only valid when tag==1) [54:56] padding u16 [56:] addresses (each 32 B)
func (*TableState) IsActive ¶
func (t *TableState) IsActive() bool
IsActive reports whether the lookup table is active (not yet deactivated).