👎 Deprecated since 0.14.0:

#[state] will be removed in a future version. Use a PDA with static seeds instead

Expand description

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.

Zero Copy Deserialization

Similar to the #[account] attribute one can enable zero copy deserialization by using the zero_copy argument:


For more, see the account attribute.