Overview
Theanchor shell command starts an interactive Node.js REPL (Read-Eval-Print Loop) with an Anchor client pre-configured according to your workspace’s Anchor.toml settings.
Command Syntax
Description
This command launches a Node.js shell with:- Anchor framework loaded and ready to use
- Connection to the configured cluster
- Wallet loaded from configuration
- All workspace programs initialized as Anchor Program clients
- Solana web3.js utilities available
Pre-configured Objects
The shell provides these objects automatically:anchor
The main Anchor framework:web3
Solana web3.js library:PublicKey
Shortcut toweb3.PublicKey:
Keypair
Shortcut toweb3.Keypair:
provider
Pre-configured Anchor provider:anchor.workspace
All workspace programs loaded as clients:Examples
Start the Shell
Check Provider Configuration
Interact with a Program
Check Balance
Fetch Account Data
Create and Send Transaction
Check Cluster Connection
Airdrop (Localnet/Devnet)
Explore Program IDL
Use Cases
Development and Testing
- Quick testing of program instructions
- Debugging account states
- Experimenting with transactions
- Prototyping client code
Account Management
- Fetching and inspecting account data
- Creating derived addresses (PDAs)
- Checking account balances and states
Transaction Testing
- Building complex transactions
- Testing different instruction combinations
- Verifying transaction signatures
Cluster Interaction
- Checking cluster status
- Requesting airdrops
- Monitoring slots and epochs
Configuration
The shell uses yourAnchor.toml configuration:
Advanced Examples
Working with PDAs
Multiple Signers
Fetching Multiple Accounts
Shell Commands
Notes
The shell automatically loads all programs defined in your workspace, making them available under
anchor.workspace.All async operations must use
await or .then() in the REPL. Top-level await is supported.See Also
- Node.js REPL - Node.js REPL documentation
- Solana Web3.js - Solana JavaScript library
- Anchor Client - Anchor client documentation