#[derive(LightTraits)]
{
// Attributes available to this derive:
#[self_program]
#[fee_payer]
#[authority]
#[cpi_context]
}
Expand description
Implements traits on the given struct required for invoking The Light system program via CPI.
§Usage
Add #[derive(LightTraits)]
to your struct which specifies the accounts
required for your Anchor program instruction. Specify the attributes
self_program
, fee_payer
, authority
, and optionally cpi_context
to
the relevant fields.
§Attributes
-
self_program
: Marks the field that represents the program invoking the light system program, i.e. your program. You need to list your program as part of the struct. -
fee_payer
: Marks the field that represents the account responsible for paying transaction fees. (Signer) -
authority
: TODO: explain authority. -
cpi_context
: TODO: explain cpi_context.
§Required accounts (must specify exact name).
light_system_program
: Light systemprogram. verifies & applies compression state transitions.registered_program_pda
: Light Systemprogram PDAnoop_program
: SPL noop programaccount_compression_authority
: TODO: explain.account_compression_program
: Account Compression program.system_program
: The Solana Systemprogram.
§Example
ⓘ
#[derive(Accounts, LightTraits)]
pub struct ExampleInstruction<'info> {
#[self_program]
pub my_program: Program<'info, MyProgram>,
#[fee_payer]
pub payer: Signer<'info>,
#[authority]
pub user: AccountInfo<'info>,
#[cpi_context]
pub cpi_context_account: AccountInfo<'info>,
pub light_system_program: AccountInfo<'info>,
pub registered_program_pda: AccountInfo<'info>,
pub noop_program: AccountInfo<'info>,
pub account_compression_authority: AccountInfo<'info>,
pub account_compression_program: AccountInfo<'info>,
pub system_program: Program<'info, System>,
}