All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Note: Version 0 of Semantic Versioning is handled differently from version 1 and above. The minor version will be incremented upon a breaking change and the patch version will be incremented for features.
avm update
command to update the Anchor CLI to the latest version (#1670).program.methods
syntax (#1732).anchor init
now come with the prettier
formatter and scripts included (#1741).pubkeys
function to methods builder to get all instruction account addresses (#1733).avm install
no longer downloads the version if already installed in the machine (#1670).anchor test
fail when used with --skip-deploy
option and without --skip-local-validator
option but there already is a running validator (#1675).(Account)Loader
(#1678).@types/bn.js
to devDependencies
in cli template (#1712).avm install
switches to the newly installed version after installation finishes (#1670).spl_token
crate (#1665).Program
type now deserializes programdata_address
only on demand (#1723).anchor clean
command that's the same as cargo clean
but preserves keypairs inside target/deploy
(#1470).anchor init
now initializes a new git repository for the workspace. This can be disabled with the --no-git
flag (#1605).anchor idl fetch
to work outside anchor workspace (#1509).AccountSysvarMismatch
error code and test cases for sysvars (#1535).std::io::Cursor
with a custom Write
impl that uses the Solana mem syscalls (#1589).require_neq
, require_keys_neq
, require_gt
, and require_gte
comparison macros (#1622).Spl.token
factory method (#1597).methods
namespace on builder functions (#1539).spl/governance
to use new errors (#1582).Cluster
's FromStr
implementation (#1362).Key
for Pubkey
again, so associated_token::*
constraints can use pubkey targets again (#1601).#[error_code]
works with just importing anchor_lang::error_code
(#1610).spl-token
coder account parsing (#1604).npm install
fallback if yarn
install doesn't work (#1643).owner = <target>
would not compile because of missing type annotation (#1648).send
and simulate
functions in provider.ts
, so they use the return value of Wallet.signTransaction
(#1527).transaction
, instruction
, simulate
and rpc
program namespaces as deprecated in favor of methods
(#1539).methods#accounts()
. ([#1548][https://github.com/project-serum/anchor/pull/1548])sol_log_data
syscall (#1608).#[derive(Default)]
(#1519).require_eq
and require_keys_eq
macros. Add default error code to require
macro (#1572).system_program
CPI wrapper functions. Make system_program
module public instead of re-exporting system_program::System
(#1629).avm use
no long prompts [y/n] if an install is needed first - it just tells the user to avm install
(#1565)AnchorError
with program stack and also a program stack for non-AnchorError
errors (#1640). AnchorError
is not returned for processed
tx that have skipPreflight
set to true
(it falls back to ProgramError
or the raw solana library error).--skip-lint
option to disable check linting introduced in (#1452) for rapid prototyping (#1482).Option<T>
mapped types (#1428).mut
(#1271).error!
and err!
macro and Result
type (#1462).
This change will break most programs. Do the following to upgrade:
ProgramResult
's to Result<()>
#[error]
to #[error_code]
Err(MyError::SomeError.into())
to Err(error!(MyError::SomeError))
and all Err(ProgramError::SomeProgramError)
to Err(ProgramError::SomeProgramError.into())
or Err(Error::from(ProgramError::SomeProgramError).with_source(source!()))
to provide file and line source of the error (with_source
is most useful with ProgramError
s. error!
already adds source information for custom and anchor internal errors).solana_program::program::invoke()
to solana_program::program::invoke().map_err(Into::into)
and solana_program::program::invoke_signed()
to solana_program::program::invoke_signed().map_err(Into::into)
Wallet
/ NodeWallet
class (#1363).Option<T>
and Vec<String>
types (#1393).seeds::program
constraint for specifying which program_id to use when deriving PDAs (#1197).Context
now has a new bumps: BTree<String, u8>
argument, mapping account name to bump seed "found" by the accounts context. This allows one to access bump seeds without having to pass them in from the client or recalculate them in the handler (#1367).methods
namespace to the program client, introducing a more ergonomic builder API (#1324).init_if_needed
behind a feature flag to decrease wrong usage (#1258).loader_account
module to account_loader
module (#1279)Accounts
trait's try_accounts
method now has an additional bumps: &mut BTreeMap<String, u8>
argument, which accumulates bump seeds (#1367).bump = <target>
targets with init
will now error. On init
only, it is required to use bump
without a target and access the seed inside function handlers via ctx.bumps.get("<pda-account-name")
. For subsequent seeds constraints (without init), it is recommended to store the bump on your account and use it as a bump = <target>
target to minimize compute units used (#1380).Coder
is now an interface and the existing class has been renamed to BorshCoder
. This change allows the generation of Anchor clients for non anchor programs (#1259).init
constraint(#1257)init_if_needed
now checks rent exemption when init is not needed (#1250).associated_token::authority
is used (#1240).workspace
and Wallet
exports (#1137).recent
to processed
and max
to finalized
(#1128)translateAddress
which currently leads to failing browser code. Now uses PublicKey
constructor instead of prototype chain constructor name checking which doesn't work in the presence of code minifying/mangling(#1138)init_if_needed
and init is not needed(#1221)programdata_address: Option<Pubkey>
field to Program
account. Will be populated if account is a program owned by the upgradable bpf loader (#1125)serialize
function because it has a default impl now. Similarly, they no longer have to implement try_deserialize
which now delegates to try_deserialize_unchecked
by default(#1156).set_inner
method to Account<'a, T>
to enable easy updates (#1177).fetch
and fetchMultiple
(#1171).AsRef<T>
for Account<'a, T>
(#1173)anchor expand
command which wraps around cargo expand
(#1160)Rc<dyn Signer>
instead of Keypair
(#975).#[repr(packed)]
to #[repr(C)]
for zero copy accounts (#1106).prelude
module or the accounts
module but not longer directly under the root.
Deprecated account types are no longer imported by the prelude (#1208).deprecated
attribute to ProgramAccount
(#1014).Cargo.toml
into extracted IDL (#1061).deprecated
attribute to Loader
(#1078).init_if_needed
attribute now checks that given attributes (e.g. space, owner, token::authority etc.) are validated even when init is not needed (#1096).ErrorCode::AccountNotInitialized
error to separate the situation when the account has the wrong owner from when it does not exist (#1024).no-log-ix-name
flag (#1057).ProgramData
and UpgradableLoaderState
can now be passed into Account
as generics. see UpgradeableLoaderState. UpgradableLoaderState
can also be matched on to get ProgramData
, but when ProgramData
is used instead, anchor does the serialization and checking that it is actually program data for you (#1095).postInstructions
and preInstructions
as a replacement for (the now deprecated) instructions
(#1007).getAccountInfo
helper method to account namespace/client (#1084).SystemAccount<'info>
account type for generic wallet addresses or accounts owned by the system program (#954)idl parse
subcommand (#941).os
and cpu
to npm package @project-serum/anchor-cli
(#976).solana-test-validator
in Anchor.toml (#834).target/types
directory now created on build to store a TypeScript types file for each program's IDL (#795).Program<T>
can now be typed with an IDL type (#795).mint::freeze_authority
keyword for mint initialization within #[derive(Accounts)]
(#835).AccountLoader
type for zero_copy
accounts with support for CPI (#792).#[account(init_if_needed)]
keyword for allowing one to invoke the same instruction even if the account was created already (#906).signer
, mut
, has_one
, owner
, raw constraints and address
(#905, #913).#[account(signer)]
constraint now enforce signer when the "cpi"
feature is enabled (#849).localnet
command for starting a local solana-test-validator
with the workspace deployed (#820).CpiContext
accounts must now be used with the accounts struct generated in the crate::cpi::accounts::*
module. These structs correspond to the accounts context for each instruction, except that each field is of type AccountInfo
(#824).--detach
flag to anchor test
(#770).associated_token
keyword for initializing associated token accounts within #[derive(Accounts)]
(#790).AccountMeta
s for Rust clients now properly set the isSigner
field (#762).Signer
type now sets isSigner to true in the IDL (#750).Program
type introduced for executable accounts (#705).Signer
type introduced for signing accounts where data is not used (#705).UncheckedAccount
type introduced as a preferred alias for AccountInfo
(#745).#[account(owner = <pubkey>)]
now requires a Pubkey
instead of an account (#691).Account
type to replace ProgramAccount
and CpiAccount
, both of which are deprecated (#686).Box
can be used with Account
types to reduce stack usage (#686).Owner
trait, which is automatically implemented by all #[account]
structs (#686).anchor-debug
only) (#681).declare_id!
(#686).Unnamed
structs instead of panic (#605).#[account(init, seeds = [...], mint::decimals = <expr>, mint::authority = <expr>)]
(#562).AsRef<AccountInfo>
for AccountInfo
wrappers (#652).trait Key
by removing AccountInfo
cloning (#652).#[account(init, seeds = [...], token = <expr>, authority = <expr>)]
to #[account(init, token::mint = <expr> token::authority = <expr>)]
(#562).#[associated]
and #[account(associated = <target>, with = <target>)]
are both removed (#612).anchor launch
command (#634).#[account(init)]
now creates the account inside the same instruction to be consistent with initializing PDAs. To maintain the old behavior of init
, replace it with #[account(zero)]
(#641).bump
must be provided when using the seeds
constraint. This has been added as an extra safety constraint to ensure that whenever a PDA is initialized via a constraint the bump used is the one created by Pubkey::find_program_address
(#641).try_from_init
has been removed from Loader
, ProgramAccount
, and CpiAccount
and replaced with try_from_unchecked
(#641).AccountsInit
trait (#641).try_from
methods for ProgramAccount
, Loader
, and ProgramState
now take in an additional program_id: &Pubkey
parameter (#660).anchor init
command "Workspace not found" regression (#598).[registry]
section in the Anchor toml (#570).anchor login <api-token>
command (#570).anchor publish <package>
command (#570).anchor_version
field to the Anchor.toml for specifying the anchor docker image to use for verifiable builds (#570).solana_version
field to the Anchor.toml for specifying the solana toolchain to use for verifiable builds (#570).init
(#587).[clusters.<network>]
Anchor.toml section has been renamed to [programs.<network>]
(#570).[workspace]
member and exclude arrays must now be filepaths relative to the workpsace root (#570).members
/ exclude
in config programs
section (#546).clusters.localnet
(#554).hex
by default for decoding Instruction (#547).CpiAccount::reload
mutates the existing struct instead of returning a new one (#526).[scripts]
test command (#550).require
macro for specifying assertions that return error codes on failure (#483).bump
keyword is added to the accounts constraints, which is used to add an optional bump seed to the end of a seeds
array. When used in conjunction with both init
and seeds
, then the program executes find_program_address
to assert that the given bump is the canonical bump (#483)..spec
suffix on TypeScript tests files (#441).belongs_to
constraint (#459).#[account(address = <expr>)]
constraint for asserting the address of an account (#400).#[account(init, token = <mint-target>, authority = <token-owner-target>...)]
constraint for initializing SPL token accounts as program derived addresses for the program. Can be used when initialized via seeds
or associated
(#400).associated_seeds!
macro for generating signer seeds for CPIs signed by an #[account(associated = <target>)]
account (#400).[scripts]
section to the Anchor.toml for specifying workspace scripts that can be run via anchor run <script>
(#400).[clusters.<network>]
table entries can now also use { address = <base58-str>, idl = <filepath-str> }
to specify workspace programs (#400).--yarn
flag in favor of using npx
(#432).&[u8]
parameter (#386).--program-name
option for build command to build a single program at a time (#362).#[account(close = <destination>)]
constraint for closing accounts and sending the rent exemption lamports to a specified destination account (#371).remaining_accounts
with CpiContext
by implementing the ToAccountMetas
trait on CpiContext
(#351).SetAuthority
instruction (#307).constraint = <expression>
added as a replacement for (the now deprecated) string literal constraints (#341).anchor.workspace
clients (#310).<program>.account.<my-account>
and <program>.state
namespaces now require explicitly invoking the fetch
API. For example, program.account.myAccount(<adddress>)
and program.state()
is now program.account.myAccount.fetch(<address>)
and program.state.fetch()
(#322).#[account(associated)]
now requires init
to be provided to create an associated account. If not provided, then the address will be assumed to exist, and a constraint will be added to ensure the correctness of the address (#318).#[state]
account discriminator to be namespaced by "state:" (#320).:
to be consistent with accounts (#321).mut
(#341).space
constraints must now be literal integers instead of literal strings (#341).program.simulate
namespace (#266).Address
type, allowing one to use Base 58 encoded strings in public APIs (#304).web3.Account
with web3.Signer
in public APIs (#296).anchor.workspace
clients can now be customized per network with [cluster.<slug>]
in the Anchor.toml (#308).--skip-build
flag to test command (301).anchor shell
command to spawn a node shell populated with an Anchor.toml based environment (#303).wallet
and cluster
settings must now be under the [provider]
table (#305).decode
API changed to decode strings directly instead of buffers (#292).encode
API removed (#292).anchor-debug
feature flag for logging (#253).RequestBuilder::new
to RequestBuilder::from
(#248).instruction::state::Ctor
struct to instruction::state::New
(#248).with
targets when creating associated acconts (#197).#[account(owner = <program>)]
constraint (#178).#[account(associated = <target>)]
and #[associated]
attributes for creating associated program accounts within programs. The TypeScript package can fetch these accounts with a new <program>.account.<account-name>.associated
(and associatedAddress
) method (#186).#[account]
s are now parsed into the IDL correctly (#177).#[state]
account's size (#121).#[account(executable)]
attribute (#140).Cluster
struct when constructing clients (#89).IdlAccount
to be namespaced by "internal"
(#128).-#![feature(proc_macro_hygiene)]
. (#139).IdlInstruction::Clear
(#107)..anchor/program-logs
directory when testing (ce5ca7).Initial release.
anchor-lang
crate providing a Rust eDSL for Solana.anchor-spl
crate providing CPI clients for Anchor programs.anchor-client
crate providing Rust clients for Anchor programs.@project-serum/anchor
package for generating TypeScript clients.