Skip to main content

Overview

The anchor 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 to web3.PublicKey:

Keypair

Shortcut to web3.Keypair:

provider

Pre-configured Anchor provider:

anchor.workspace

All workspace programs loaded as clients:

Examples

Start the Shell

Output:

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 your Anchor.toml configuration:
Override cluster:
Override wallet:

Advanced Examples

Working with PDAs

Multiple Signers

Fetching Multiple Accounts

Shell Commands

Notes

Use the shell for rapid prototyping and testing without writing separate script files.
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.
Be careful when using the shell with mainnet-beta. All transactions are real and irreversible.

See Also