Thank you for your interest in contributing to Anchor! All contributions are welcome no matter how big or small. This includes (but is not limited to) filing issues, adding documentation, fixing bugs, creating examples, and implementing features.
If you're looking to get started, check out good first issues or issues where help is wanted. PRs that only correct typos or make minor wording adjustments will be rejected. Fixing typos alongside other non-trivial engineering work is welcome.
If you're considering larger changes or self motivated features, please file an issue and engage with the maintainers in Discord.
If you'd like to contribute, please claim an issue by commenting, forking, and opening a pull request, even if empty. This allows the maintainers to track who is working on what issue as to not overlap work.
Pull requests should usually target master.
If your change is breaking, open the pull request against anchor-next
instead of master.
Please follow these guidelines:
Before coding:
- choose a branch name that describes the issue you're working on
- enable commit signing
While coding:
- Submit a draft PR asap
- Only change code directly relevant to your PR. Sometimes you might find some code that could really need some refactoring. However, if it's not relevant to your PR, do not touch it. File an issue instead. This allows the reviewer to focus on a single problem at a time.
- If you write comments, do not exceed 80 chars per line. This allows contributors who work with multiple open windows to still read the comments without horizontally scrolling.
- Write adversarial tests. For example, if you're adding a new account type, do not only write tests where the instruction succeeds. Also write tests that test whether the instruction fails, if a check inside the new type is violated.
After coding:
- If you've moved code around, build the docs with
cargo doc --openand adjust broken links - Adjust the cli templates if necessary
- If you've added a new folder to the
testsdirectory, add it to the CI. - Before opening a PR, build, test, and run formatting and lints locally; see the sections below for commands.
Use the commands below to validate changes before opening a PR.
# Rust workspace
cargo build
# TypeScript packages (run in the package/workspace you changed)
yarn buildcargo testyarn testRun yarn test in the relevant package/workspace (for example
ts/packages/anchor).
anchor testThese are the integration tests under the root tests/ folder.
Contributors should run the tests that cover their changes and/or add new
test cases.
Integration and other non-Rust tests depend on local TS package linking. You can set this up in either of these ways:
- Recommended: run
./setup-tests.sh - Manual: use
yarn linkto link local Anchor TS packages
For anchor test, ensure the anchor command points to your local CLI
build (for example via ./setup-tests.sh, cargo install --path cli, or
running the binary from target directly).
cargo install --path cli writes anchor into ~/.cargo/bin/anchor.
AVM also manages anchor in that same location via symlink, so installing
from Cargo overrides AVM version selection until reverted.
To restore AVM-managed behavior:
- uninstall/remove the Cargo-installed binary (
cargo uninstall anchor-cliorrm ~/.cargo/bin/anchor) - re-run AVM so it rewrites the symlink
If you have edited any Rust or TypeScript/JavaScript code, ensure it is correctly formatted and compatible with our lint suite; this will ensure CI passes and help us quickly review your contribution.
In the root workspace, run:
# Ensure you have the latest nightly version with `rustup update nightly`
cargo +nightly fmt
cargo clippy --all-targets -- -D warningsEnter the relevant JS package (e.g. tests/, or ts/packages/anchor) and run:
yarn
yarn lint:fix