Attribute Macro anchor_attribute_state::state[][src]

#[state]

The #[state] attribute defines the program’s state struct, i.e., the program’s global account singleton giving the program the illusion of state.

To allocate space into the account on initialization, pass in the account size into the macro, e.g., #[state(SIZE)]. Otherwise, the size of the account returned by the struct’s new constructor will determine the account size. When determining a size, make sure to reserve enough space for the 8 byte account discriminator prepended to the account. That is, always use 8 extra bytes.