Skip to content
Development
Command

/deploy

Deploy Solana program (devnet first, then mainnet)

From plugin
solana-ai-kit
10130 skills15 agents30 commands7 MCP
Install
> /plugin marketplace add solanabr/solana-ai-kit
> /plugin install solana-ai-kit@stbr

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/deploy

Context preview

What this command does when you run it.

Deploy Solana program (devnet first, then mainnet)

Command definition

deploy.md
description: "Deploy Solana program (devnet first, then mainnet)"

You are deploying a Solana program. **ALWAYS test on devnet before mainnet.**

Related Skills

  • [deployment.md](../skills/deployment.md) - Full deployment workflow details
  • [security.md](../skills/ext/solana-dev/skill/references/security.md) - Pre-deployment security checklist

Step 1: Identify Target Network

echo "๐ŸŽฏ Deployment Target Selection"
echo ""
echo "Choose deployment target:"
echo "  1. devnet (testing - safe, free SOL)"
echo "  2. mainnet (production - REAL SOL, IRREVERSIBLE)"
echo ""

# Check current config
CURRENT_NETWORK=$(solana config get | grep "RPC URL" | awk '{print $3}')
echo "Current network: $CURRENT_NETWORK"

**IMPORTANT**: If this is a new program, **ALWAYS deploy to devnet first**.

---

DEVNET DEPLOYMENT

Step D1: Configure Devnet

echo "๐ŸŒ Configuring for devnet..."

solana config set --url devnet

# Verify
solana config get
# Should show: RPC URL: https://api.devnet.solana.com

Step D2: Verify Build

echo "๐Ÿ”จ Building program..."

# Build
if [ -f "Anchor.toml" ]; then
    anchor build
else
    cargo build-sbf
fi

# Check program exists
ls -lh target/deploy/*.so

Step D3: Fund Wallet

echo "๐Ÿ’ฐ Checking wallet balance..."

solana address
solana balance

# If balance is low, airdrop (devnet only!)
solana airdrop 2

solana balance

Step D4: Deploy to Devnet

echo "๐Ÿš€ Deploying to devnet..."

if [ -f "Anchor.toml" ]; then
    anchor deploy --provider.cluster devnet
else
    solana program deploy target/deploy/program.so
fi

# Get program ID
PROGRAM_ID=$(solana address -k target/deploy/program-keypair.json)
echo "โœ… Program deployed: $PROGRAM_ID"

# Save program ID
echo $PROGRAM_ID > .program-id-devnet

Step D5: Verify Devnet Deployment

echo "๐Ÿ” Verifying deployment..."

solana program show $PROGRAM_ID

# Explorer link
echo ""
echo "๐Ÿ“ก Explorer: https://explorer.solana.com/address/$PROGRAM_ID?cluster=devnet"

Step D6: Test on Devnet

echo "๐Ÿงช Running devnet tests..."

if [ -f "Anchor.toml" ]; then
    anchor test --skip-build --skip-deploy
fi

# Or run custom integration tests

Devnet Checklist

  • [ ] Program deployed to devnet
  • [ ] Program ID saved
  • [ ] Upgrade authority verified
  • [ ] Program visible on explorer
  • [ ] Basic functionality tested
  • [ ] Integration with frontend tested

**Next step**: Test thoroughly on devnet for multiple days before mainnet.

---

MAINNET DEPLOYMENT

โš ๏ธ CRITICAL PRE-DEPLOYMENT CHECKLIST

**STOP: Do NOT proceed to mainnet without ALL items checked:**

  • [ ] All tests passing (unit + integration + fuzz)
  • [ ] Security audit completed (use /audit-solana)
  • [ ] CU usage optimized and verified
  • [ ] **Devnet testing successful (multiple days)**
  • [ ] Program audited by professional firm (for financial programs)
  • [ ] Emergency procedures documented
  • [ ] Upgrade authority strategy decided
  • [ ] Monitoring/alerts configured

Step M1: CONFIRMATION REQUIRED

๐Ÿšจ MAINNET DEPLOYMENT CONFIRMATION REQUIRED ๐Ÿšจ

Network: Solana Mainnet-Beta
Program: [program name]
Estimated Cost: [X SOL for deployment + buffer]

This action will:
- Deploy program to MAINNET (IRREVERSIBLE)
- Spend REAL SOL
- Make program publicly accessible
- Potentially handle user funds

โš ๏ธ  HAVE YOU COMPLETED:
- [ ] Security audit
- [ ] Professional code review
- [ ] Extensive devnet testing (multiple days)
- [ ] Emergency procedures

Type 'DEPLOY TO MAINNET' to confirm:

**DO NOT PROCEED WITHOUT USER CONFIRMATION**

Step M2: Configure Mainnet

echo "๐ŸŒ Configuring for mainnet..."

solana config set --url mainnet-beta

# VERIFY
solana config get
# Must show: RPC URL: https://api.mainnet-beta.solana.com

# Check wallet and balance
solana address
solana balance
# Need ~3-5 SOL for deployment

Step M3: Final Build Verification

echo "๐Ÿ”จ Final build verification..."

# Clean build
anchor clean
anchor build --verifiable

# Verify program size
ls -lh target/deploy/*.so

# Run all tests one more time
anchor test

# Security checks
cargo clippy -- -W clippy::all
cargo audit

Step M4: Calculate Deployment Cost

# Estimate deployment cost
solana program deploy target/deploy/program.so --dry-run

# Ensure you have 2x this amount for safety

Step M5: Deploy to Mainnet

echo "โš ๏ธ  FINAL CONFIRMATION"
echo "Network: $(solana config get | grep 'RPC URL')"
echo "Deployer: $(solana address)"
echo "Balance: $(solana balance)"

# Deploy
anchor deploy --provider.cluster mainnet-beta

# SAVE PROGRAM ID IMMEDIATELY
PROGRAM_ID=$(solana address -k target/deploy/program-keypair.json)
echo "๐ŸŽฏ DEPLOYED PROGRAM ID: $PROGRAM_ID"

# Save to file
echo $PROGRAM_ID > .program-id-mainnet

Step M6: Verify Mainnet Deployment

# Verify program is on mainnet
solana program show $PROGRAM_ID

# Check upgrade authority
UPGRADE_AUTH=$(solana program show $PROGRAM_ID | grep "Upgrade Authority" | awk '{print $3}')
echo "Upgrade Authority: $UPGRADE_AUTH"

# Explorer
echo "Explorer: https://explorer.solana.com/address/$PROGRAM_ID"

# Verify program binary
solana program dump $PROGRAM_ID program-dump.so
diff target/deploy/program.so program-dump.so

Step M7: Initial Mainnet Testing

**Test with SMALL amounts first!**

# Test read-only operations first
# Test write operations with MINIMAL amounts (0.01 SOL)
# Monitor for any issues

Step M8: Post-Deployment

# Save deployment info
cat > deployment-mainnet.json <<EOF
{
  "programId": "$PROGRAM_ID",
  "deployedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
  "deployer": "$(solana address)",
  "network": "mainnet-beta",
  "upgradeAuthority": "$UPGRADE_AUTH"
}
EOF

# Update frontend
echo "NEXT_PUBLIC_PROGRAM_ID=$PROGRAM_ID" >> .env.production

Step M9: Upgrade Authority Staging

<!-- Adapted from sendaifun/solana-new (deploy-to-mainnet), MIT --> Don't free

Read more
Ships withsolana-ai-kit

Production-ready Claude Code configuration for full-stack Solana development. Combines best practices from multiple sources into an agent-optimized, token-efficient config you can install and adapt to your specific project.

Get the whole plugin

Other commands on solana-ai-kit.