DEV Community

Zak R.
Zak R.

Posted on

Deploying Solana Anchor Programs Easily with Rocket Anchor

If you're a developer working with Anchor on Solana, you know the drill. You build your powerful program, and then... you're stuck writing a tangled mess of ad-hoc scripts for deployment, upgrades, and account initialization. It's time-consuming, error-prone, and just plain frustrating.

What if you could have a smooth, repeatable, Hardhat-style workflow?

Meet Rocket Anchor, a new open-source tool designed to save you from deployment headaches and streamline your entire process. This guide will walk you through exactly what it is and how to get started.

What is Rocket Anchor?

Rocket Anchor is a CLI and programmatic tool that brings the developer-friendly experience of tools like Hardhat to the Anchor ecosystem.

Its main goal is to solve the "last mile" problem of Anchor development:

  • It replaces manual scripts with a clean, config-based CLI workflow.
  • It introduces "seeding," a powerful concept for initializing accounts, PDAs, and program state right after deployment.
  • It's built for teams, making it easy to manage deployments across different networks (devnet, mainnet) without changing your code.

Key Features

  • Hardhat-Inspired CLI: Get a familiar workflow with commands like init, deploy, and seed.
  • Powerful Seeding: Run scripts after deployment to initialize program state, create PDAs, or set up initial data. This is a massive time-saver.
  • Network Management: Easily configure different networks (like devnet, testnet, mainnet, custom-network) in a single config file, complete with RPC endpoints and keypair paths.
  • Programmatic API: Need to integrate Rocket Anchor into your existing TypeScript toolchain? You can import and use it directly.

Installation

You can install Rocket Anchor globally to use it as a CLI tool across all your projects, or locally as a devDependency in a specific project.

Global Install:

npm install -g rocket-anchor
Enter fullscreen mode Exit fullscreen mode

Local Install:

npm install --save-dev rocket-anchor
Enter fullscreen mode Exit fullscreen mode

Getting Started: Your First Deployment

Let's walk through the entire workflow from zero to a seeded deployment.

Step 1: Initialize Rocket Anchor

In the root of your Anchor project, run the init command:

npx ra init
Enter fullscreen mode Exit fullscreen mode

This will create a new file named ra.config.ts in your project's root. This is where you'll define all your networks and deployment configurations.

Step 2: Configure Your Networks

Open the newly created ra.config.ts. This is where you'll tell Rocket Anchor how to connect to different Solana clusters.

A typical configuration might look something like this:

// ra.config.ts
import { RocketAnchorConfig } from 'rocket-anchor';

const config: RocketAnchorConfig = {
  networks: {
    // Local validator
    localnet: {
      url: "[http://127.0.0.1:8899](http://127.0.0.1:8899)",
      keypair: "/path/to/your/localnet/keypair.json",
    },
    // Devnet
    devnet: {
      url: "[https://api.devnet.solana.com](https://api.devnet.solana.com)",
      keypair: "/path/to/your/devnet/keypair.json",
    },
    // Mainnet
    mainnet: {
      url: "[https://api.mainnet-beta.solana.com](https://api.mainnet-beta.solana.com)",
      keypair: "/path/to/your/mainnet/keypair.json",
    }
  },
};

export default config;
Enter fullscreen mode Exit fullscreen mode

Step 3: (Optional but Recommended) Create Seed Scripts

This is where the magic happens. "Seeding" is the process of initializing your program's state right after deployment.

Create a seeds/ directory and an index.ts file inside it (seeds/index.ts). Here, you'll define a SeedConfig array.

// seeds/index.ts

import { SeedConfig } from 'rocket-anchor';

export const seeds: SeedConfig[] = [
  {
    program: 'counter', // a name for your program
    initialize: {
      function: 'initialize',
      accounts: {
        counter: 'pda:counter',
        authority: 'signer',
        systemProgram: 'systemProgram',
      },
      args: [0], // initial_count
    },
    seeds: [
      {
        function: 'increment',
        accounts: {
          counter: 'pda:counter',
          authority: 'signer',
        },
        args: [],
        repeat: 5, // Run 5 times
      },
    ],
  },
];

export default seeds;
Enter fullscreen mode Exit fullscreen mode

Step 4: Deploy and Seed!

You're all set. Now, to deploy your program to devnet and run the seed scripts immediately after, you just run one command:

npx ra deploy --network devnet --seed
Enter fullscreen mode Exit fullscreen mode

Rocket Anchor will handle:

  1. Connecting to the correct network (devnet).
  2. Using the correct keypair.
  3. Deploying your Anchor program.
  4. Once deployed, it will run the seed scripts you defined for that program.

You're live! No more manual solana program deploy commands or separate initialize.ts scripts to run.


Conclusion

Rocket Anchor fills a much-needed gap in the Solana development workflow. By adopting a config-based and scriptable approach to deployments and seeding, it saves time, reduces errors, and lets you focus on what matters: building your program's logic.

Always remember to test thoroughly on devnet before deploying to mainnet. Happy building!

Top comments (0)