Expand description

The prelude contains all commonly used components of the crate. All programs should include it via anchor_lang::prelude::*;.

Re-exports

pub use super::AccountDeserialize;
pub use super::AccountSerialize;
pub use super::Accounts;
pub use super::AccountsExit;
pub use super::AccountsInit;
pub use super::ToAccountInfo;
pub use super::ToAccountInfos;
pub use super::ToAccountMetas;
pub use borsh;
pub use thiserror;

Macros

Print a message to the log

Structs

Account information

Account metadata used to define Instructions

Clock represents network time. Members of Clock start from 0 upon network boot. The best way to map Clock to wallclock time is to use current Slot, as Epochs vary in duration (they start short and grow as the network progresses).

Provides non-argument inputs to the program.

Container for any account not owned by the current program.

Context speciying non-argument inputs for cross-program-invocations.

The Ctor accounts that can be used to create any account within the program itself (instead of creating the account on the client).

Boxed container for a deserialized account. Use this to reference any account owned by the currently executing program.

Boxed container for the program state singleton.

Container for sysvars.

Enums

Reasons the program may fail

Traits

A data-structure that can be de-serialized from binary format by NBOR.

A data-structure that can be serialized into binary format by NBOR.

Functions

Return the next AccountInfo or a NotEnoughAccountKeys error.

Type Definitions

Attribute Macros

Executes the given access control method before running the decorated instruction handler. Any method in scope of the attribute can be invoked with any arguments from the associated instruction handler.

A data structure representing a Solana account, implementing various traits:

Generates Error and type Result<T> = Result<T, Error> types to be used as return types from Anchor instruction handlers. Importantly, the attribute implements From on the ErrorCode to support converting from the user defined error enum into the generated Error.

The #[interface] attribute allows one to define an external program dependency, without having any knowledge about the program, other than the fact that it implements the given trait.

The #[program] attribute defines the module containing all instruction handlers defining all entries into a Solana program.

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

Derive Macros

Implements an Accounts deserializer on the given struct, applying any constraints specified via inert #[account(..)] attributes upon deserialization.