Install and manage multiple versions of the Anchor CLI with AVM for version-specific development and verifiable builds.
Anchor Version Manager (AVM) is a command-line tool for managing multiple installations of the Anchor CLI. It allows you to easily switch between Anchor versions for different projects, which is essential for:
Working with projects that require specific Anchor versions
Creating verifiable builds that match deployed programs
# Version with commit hashavm install 0.30.1-cfe82aa682138f7c6c58bf7a78f48f7d63e9e466# Full commit hashavm install cfe82aa682138f7c6c58bf7a78f48f7d63e9e466# Short commit hash (minimum 7 characters)avm install cfe82aa
Options:
--force - Force installation even if version exists
--from-source - Build from source instead of downloading prebuilt binaries
--verify - Also install solana-verify tool
--path <PATH> - Install from a local Anchor repository
Examples:
# Force reinstall a versionavm install 0.32.1 --force# Build from sourceavm install 0.32.1 --from-source# Install with solana-verifyavm install 0.32.1 --verify# Install from local pathavm install --path ~/projects/anchor
Prebuilt binaries are available for most releases. Use --from-source if you need a custom build or encounter binary compatibility issues.
Use different Anchor versions for different projects:
# Project A (uses Anchor 0.32.1)cd ~/projects/project-aavm use 0.32.1anchor build# Project B (uses Anchor 0.30.1)cd ~/projects/project-bavm use 0.30.1anchor build
AVM is essential for creating verifiable builds that match deployed programs:
# Install the version used for the deployed programavm install 0.32.1# Use that versionavm use 0.32.1# Build verifiablyanchor build --verifiable# Verify against deployed programanchor verify -p my_program <program-id>
Test your program against different Anchor versions:
#!/bin/bash# test-versions.shVERSIONS=("0.30.1" "0.31.0" "0.32.1")for version in "${VERSIONS[@]}"; do echo "Testing with Anchor $version" avm use $version anchor test || echo "Tests failed on $version"done