What Anchor does for you
- Account validation. You declare the accountsAccountsEverything on Solana (balances, tokens, programs, app data) lives in accounts: records at an address, each with an owner that is allowed to change it.Learn more (Accounts: Everything on Solana (balances, tokens, programs, app data) lives in accounts: records at an address, each with an owner that is allowed to change it.) each instruction expects, with constraints such as owner, signer, and PDAProgram-derived addressesA PDA is an address derived from a program plus some seeds. It has no private key, so only that program can sign for it, which makes it handy for storing app state at predictable addresses.Learn more (Program-derived addresses: A PDA is an address derived from a program plus some seeds. It has no private key, so only that program can sign for it, which makes it handy for storing app state at predictable addresses.) seeds, and Anchor checks them before your code runs.
- Serialization. Instruction arguments and account data are encoded and decoded for you.
- An IDL. Anchor generates an IDL, a JSON description of your program’s interface. Clients and tools such as Codama use it to generate typed clients.
- A CLI and project template.
anchor init,anchor build,anchor test, andanchor program deploycover the whole loop. A new project includes a Rust test template that uses LiteSVM.
Security: What Anchor does not check for youAnchor validates what you declare, and nothing else:
UncheckedAccountandAccountInfoskip owner, type, and signer checks. Anchor requires a/// CHECK:comment on each one; that comment should name the check your instruction performs instead.- Relationships between accounts need constraints.
Account<'info, Vault>proves the account is aVault, not that it is this user’s vault. Addhas_one = owner,seeds, or aconstraintto bind it. init_if_neededruns your instruction on an account that may already exist. Check its state so a caller can’t reset an initialized account.- Arithmetic wraps in release builds unless
overflow-checks = trueis set in the workspaceCargo.toml. New Anchor projects set it; keep it.
Get started
Build your first program
Create, build, and test an Anchor program, then read every file it contains.
Install Anchor
Install Rust, the Solana CLI, and Anchor with one command.
Anchor CLI basics
Create, build, test, and deploy Anchor projects.
Anchor events
Define, emit, decode, and subscribe to typed program events.
anchor CLI, is in the Anchor documentation.
Prefer to work without a framework? See Rust programs.