Skip to main content

Module instruction

Module instruction 

Source
Expand description

Utilities to build instructions for programs with compressed accounts.

§Overview

This module provides types and utilities for building Solana instructions that work with compressed accounts. The main workflow involves:

 |- Client
 |  |- Get ValidityProof from RPC.
 |  |- pack accounts with PackedAccounts into PackedAddressTreeInfo and PackedStateTreeInfo.
 |  |- pack CompressedAccountMeta.
 |  |- Build Instruction from packed accounts and CompressedAccountMetas.
 |  |_ Send transaction
 |
 |_ Custom Program
    |- use PackedAddressTreeInfo to create a new address.
    |- use CompressedAccountMeta to instantiate a LightAccount struct.
    |
    |_ Light System Program CPI

§Main Types

§Compressed Account Metas

Instruction data types to pass compressed account metadata into instructions. CompressedAccountMeta and variations with and without lamports and addresses are used to instantiate LightAccount structs in your program.

§Packed Structs Pattern

Structs prefixed with Packed (eg PackedAddressTreeInfo, PackedStateTreeInfo) are instruction data structs that contain account indices instead of pubkeys to reduce instruction size.

  • Packed* structs: Contain indices (u8) for use in instruction data.
  • Non-Packed structs: Contain pubkeys (Pubkey) for use in the client, and are returned by RPC methods.
  • PackedAccounts: Manages account deduplication and index assignment to create Packed* structs.

Modules§

account_info
account_meta

Structs§

AddressTreeInfo
CompressedProof
MerkleContext
PackedAccounts
Packs accounts and creates indices for instruction building (client-side).
PackedAddressTreeInfo
Packed address tree info for instruction data. Contains indices to address tree accounts and root index.
PackedMerkleContext
PackedStateTreeInfo
SystemAccountMetaConfig
Configuration for Light system program accounts when building instructions.
SystemAccountPubkeys
ValidityProof

Traits§

AccountMetasVec
PackedAddressTreeInfoExt
Extension trait for PackedAddressTreeInfo SDK-specific methods. Since PackedAddressTreeInfo is defined in light-compressed-account, we use an extension trait to add methods that depend on SDK types.

Functions§

get_light_system_account_metas
InvokeSystemCpi v1.
get_light_system_account_metas_v2
Can be used in client to add system account metas.
pack_address_tree_info
Returns a PackedAddressTreeInfo and fills up remaining_accounts based on the given merkle_context. Packs Merkle tree account first. Packs queue account second.
pack_address_tree_infos
Returns an iterator of PackedAddressTreeInfo and fills up remaining_accounts based on the given merkle_contexts.
pack_merkle_contextDeprecated
pack_merkle_contextsDeprecated
unpack_address_tree_info
unpack_address_tree_infos