Skip to content
OpenSmartRoute
Skillv1.0.0

solana

You are an expert in Solana blockchain development. You help developers build on-chain programs (smart contracts) in Rust, interact with the Solana network using @solana/web3.js, create tokens (SPL),

by terminalskills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from terminalskills/skills (skills/solana/SKILL.md). Install upstream with npx skills add terminalskills/skills --skill solana. Copyright stays with the author (Apache-2.0).

Solana — High-Performance Blockchain Development

You are an expert in Solana blockchain development. You help developers build on-chain programs (smart contracts) in Rust, interact with the Solana network using @solana/web3.js, create tokens (SPL), build NFT collections, and integrate with wallets — leveraging Solana's 400ms block times, parallel transaction processing, and sub-cent fees for high-throughput applications.

Core Capabilities

On-Chain Program (Rust)

// programs/counter/src/lib.rs — Solana program with Anchor
use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod counter {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
        let counter = &mut ctx.accounts.counter;
        counter.count = 0;
        counter.authority = ctx.accounts.authority.key();
        counter.bump = ctx.bumps.counter;
        Ok(())
    }

    pub fn increment(ctx: Context<Increment>) -> Result<()> {
        let counter = &mut ctx.accounts.counter;
        counter.count = counter.count.checked_add(1)
            .ok_or(ErrorCode::Overflow)?;
        emit!(CounterIncremented {
            count: counter.count,
            authority: ctx.accounts.authority.key(),
        });
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(
        init,
        payer = authority,
        space = 8 + Counter::INIT_SPACE,
        seeds = [b"counter", authority.key().as_ref()],
        bump,
    )]
    pub counter: Account<'info, Counter>,
    #[account(mut)]
    pub authority: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
pub struct Increment<'info> {
    #[account(
        mut,
        seeds = [b"counter", authority.key().as_ref()],
        bump = counter.bump,
        has_one = authority,
    )]
    pub counter: Account<'info, Counter>,
    pub authority: Signer<'info>,
}

#[account]
#[derive(InitSpace)]
pub struct Counter {
    pub count: u64,
    pub authority: Pubkey,
    pub bump: u8,
}

#[event]
pub struct CounterIncremented {
    pub count: u64,
    pub authority: Pubkey,
}

#[error_code]
pub enum ErrorCode {
    #[msg("Counter overflow")]
    Overflow,
}

Client SDK (TypeScript)

import { Connection, PublicKey, Keypair, clusterApiUrl } from "@solana/web3.js";
import { Program, AnchorProvider, web3, BN } from "@coral-xyz/anchor";
import { IDL, Counter } from "./idl/counter";

const connection = new Connection(clusterApiUrl("devnet"), "confirmed");

// Read account data
async function getCounter(authority: PublicKey): Promise<{ count: number }> {
  const [counterPDA] = PublicKey.findProgramAddressSync(
    [Buffer.from("counter"), authority.toBuffer()],
    PROGRAM_ID,
  );

  const program = new Program<Counter>(IDL, PROGRAM_ID, provider);
  const account = await program.account.counter.fetch(counterPDA);
  return { count: account.count.toNumber() };
}

// Send transaction
async function increment(wallet: AnchorProvider): Promise<string> {
  const program = new Program<Counter>(IDL, PROGRAM_ID, wallet);
  const [counterPDA] = PublicKey.findProgramAddressSync(
    [Buffer.from("counter"), wallet.publicKey.toBuffer()],
    PROGRAM_ID,
  );

  const tx = await program.methods
    .increment()
    .accounts({ counter: counterPDA, authority: wallet.publicKey })
    .rpc();

  return tx;   // Transaction signature
}

SPL Token Creation

# Create a new token
spl-token create-token --decimals 6
# Token: 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU

# Create token account and mint
spl-token create-account 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU
spl-token mint 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU 1000000

# Transfer
spl-token transfer 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU 100 RECIPIENT_ADDRESS

Installation

# Solana CLI
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
solana config set --url devnet

# Anchor framework
cargo install --git https://github.com/coral-xyz/anchor avm --force
avm install latest && avm use latest

# New project
anchor init my-program
anchor build
anchor test
anchor deploy

Best Practices

  1. Anchor framework — Use Anchor for account validation, (de)serialization, and error handling; raw Solana is error-prone
  2. PDAs for program-owned accounts — Use Program Derived Addresses with seeds; deterministic, no private key needed
  3. Account size planning — Solana accounts must declare size at creation; use #[derive(InitSpace)] for automatic calculation
  4. Checked math — Use checked_add, checked_mul to prevent overflow; Solana doesn't have SafeMath by default
  5. Rent exemption — Accounts need minimum balance for rent exemption (~0.002 SOL); Anchor handles this automatically
  6. CPI for composability — Use Cross-Program Invocations to call other programs (token transfers, DEX swaps)
  7. Events for indexing — Emit events with emit!; indexers (Helius, Shyft) pick them up for off-chain data
  8. Test on devnet — Use solana airdrop 2 for free devnet SOL; test thoroughly before mainnet deployment

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/terminalskills-skills-solana/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

terminalskills-skills-solana.ocm.jsonjson
{
  "ocm": "1",
  "id": "terminalskills-skills-solana",
  "kind": "skill",
  "name": "solana",
  "description": "You are an expert in Solana blockchain development. You help developers build on-chain programs (smart contracts) in Rust, interact with the Solana network using @solana/web3.js, create tokens (SPL), build NFT collections, and integrate with wallets — leveraging Solana's 400ms block times, parallel transaction processing, and sub-cent fees for high-throughput applications.",
  "publisher": "terminalskills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "blockchain",
      "rust",
      "smart-contracts",
      "defi",
      "nft",
      "high-performance",
      "web3",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "You are an expert in Solana blockchain development. You help developers build on-chain programs (smart contracts) in Rust, interact with the Solana network using @solana/web3.js, create tokens (SPL), build NFT collections, and integrate with wallets — leveraging Solana's 400ms block times, parallel transaction processing, and sub-cent fees for high-throughput applications."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/terminalskills/skills",
      "path": "skills/solana/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/terminalskills/skills/blob/HEAD/skills/solana/SKILL.md",
      "key": "terminalskills/skills/skills/solana/SKILL.md"
    },
    "license": "Apache-2.0"
  },
  "instructions": "# Solana — High-Performance Blockchain Development\n\nYou are an expert in Solana blockchain development. You help developers build on-chain programs (smart contracts) in Rust, interact with the Solana network using @solana/web3.js, create tokens (SPL), build NFT collections, and integrate with wallets — leveraging Solana's 400ms block times, parallel transaction processing, and sub-cent fees for high-throughput applications.\n\n## Core Capabilities\n\n### On-Chain Program (Rust)\n\n```rust\n// programs/counter/src/lib.rs — Solana program with Anchor\nuse anchor_lang::prelude::*;\n\ndeclare_id!(\"Fg6PaFpoG",
  "cost": {
    "context_tokens": 1296
  }
}

Fetch it by URL: GET /api/v1/registry/terminalskills-skills-solana/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.