[−][src]Crate anchor_lang
Anchor ⚓ is a framework for Solana's Sealevel runtime providing several convenient developer tools.
- Rust eDSL for writing safe, secure, and high level Solana programs
- IDL specification
- TypeScript package for generating clients from IDL
- CLI and workspace management for developing complete applications
If you're familiar with developing in Ethereum's Solidity, Truffle, web3.js or Parity's Ink!, then the experience will be familiar. Although the syntax and semantics are targeted at Solana, the high level workflow of writing RPC request handlers, emitting an IDL, and generating clients from IDL is the same.
For detailed tutorials and examples on how to use Anchor, see the guided tutorials or examples in the GitHub repository.
Presented here are the Rust primitives for building on Solana.
Modules
prelude | The prelude contains all commonly used components of the crate.
All programs should include it via |
Structs
Context | Provides non-argument inputs to the program. |
CpiAccount | Container for any account not owned by the current program. |
CpiContext | Context speciying non-argument inputs for cross-program-invocations. |
ProgramAccount | Container for a serializable |
Sysvar | Container for sysvars. |
Traits
AccountDeserialize | A data structure that can be deserialized from an |
AccountSerialize | A data structure that can be serialized and stored in an |
Accounts | A data structure of accounts that can be deserialized from the input
of a Solana program. Due to the freewheeling nature of the accounts array,
implementations of this trait should perform any and all constraint checks
(in addition to any done within |
AccountsInit | A data structure of accounts providing a one time deserialization upon initialization, i.e., when the data array for a given account is zeroed. For all subsequent deserializations, it's expected that Accounts is used. |
AnchorDeserialize | Default serialization format for anchor instructions and accounts. |
AnchorSerialize | Default serialization format for anchor instructions and accounts. |
ToAccountInfo | Transformation to an |
ToAccountInfos | Transformation to |
ToAccountMetas | Transformation to |
Attribute Macros
access_control | 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. |
account | A data structure representing a Solana account. |
program | The module containing all instruction handlers defining all entries to the Solana program. |
Derive Macros
Accounts | Implements an |
AnchorDeserialize | Default serialization format for anchor instructions and accounts. |
AnchorSerialize | Default serialization format for anchor instructions and accounts. |