solana-dev

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Solana Development Skill (framework-kit-first)

Solana开发技能(优先使用framework-kit)

What this Skill is for

本技能的适用场景

Use this Skill when the user asks for:
  • Solana dApp UI work (React / Next.js)
  • Wallet connection + signing flows
  • Transaction building / sending / confirmation UX
  • On-chain program development (Anchor or Pinocchio)
  • Client SDK generation (typed program clients)
  • Local testing (LiteSVM, Mollusk, Surfpool)
  • Security hardening and audit-style reviews
  • Confidential transfers (Token-2022 ZK extension)
当用户询问以下内容时使用本技能:
  • Solana dApp UI开发(React / Next.js)
  • 钱包连接 + 签名流程
  • 交易构建 / 发送 / 确认用户体验
  • 链上程序开发(Anchor或Pinocchio)
  • 客户端SDK生成(类型化程序客户端)
  • 本地测试(LiteSVM、Mollusk、Surfpool)
  • 安全加固与审计式评审
  • 保密转账(Token-2022 ZK扩展)

Default stack decisions (opinionated)

默认技术栈决策(带有主观倾向)

  1. UI: framework-kit first
  • Use
    @solana/client
    +
    @solana/react-hooks
    .
  • Prefer Wallet Standard discovery/connect via the framework-kit client.
  1. SDK: @solana/kit first
  • Prefer Kit types (
    Address
    ,
    Signer
    , transaction message APIs, codecs).
  • Prefer
    @solana-program/*
    instruction builders over hand-rolled instruction data.
  1. Legacy compatibility: web3.js only at boundaries
  • If you must integrate a library that expects web3.js objects (
    PublicKey
    ,
    Transaction
    ,
    Connection
    ), use
    @solana/web3-compat
    as the boundary adapter.
  • Do not let web3.js types leak across the entire app; contain them to adapter modules.
  1. Programs
  • Default: Anchor (fast iteration, IDL generation, mature tooling).
  • Performance/footprint: Pinocchio when you need CU optimization, minimal binary size, zero dependencies, or fine-grained control over parsing/allocations.
  1. Testing
  • Default: LiteSVM or Mollusk for unit tests (fast feedback, runs in-process).
  • Use Surfpool for integration tests against realistic cluster state (mainnet/devnet) locally.
  • Use solana-test-validator only when you need specific RPC behaviors not emulated by LiteSVM.
  1. UI:优先使用framework-kit
  • 使用
    @solana/client
    +
    @solana/react-hooks
    .
  • 优先通过framework-kit客户端使用钱包标准的发现/连接功能。
  1. SDK:优先使用@solana/kit
  • 优先使用Kit类型(
    Address
    ,
    Signer
    , 交易消息API, 编解码器).
  • 优先使用
    @solana-program/*
    指令构建器,而非手动编写的指令数据。
  1. 遗留兼容性:仅在边界使用web3.js
  • 如果必须集成依赖web3.js对象(
    PublicKey
    ,
    Transaction
    ,
    Connection
    )的库, 使用
    @solana/web3-compat
    作为边界适配器。
  • 不要让web3.js类型渗透到整个应用中;将它们限制在适配器模块内。
  1. 程序开发
  • 默认:Anchor(迭代速度快、支持IDL生成、工具成熟)。
  • 性能/体积优化:当需要CU优化、最小二进制体积、零依赖或对解析/内存分配的精细控制时,使用Pinocchio。
  1. 测试
  • 默认:使用LiteSVM或Mollusk进行单元测试(反馈速度快,进程内运行)。
  • 使用Surfpool在本地针对真实集群状态(主网/测试网)进行集成测试。
  • 仅当需要LiteSVM未模拟的特定RPC行为时,才使用solana-test-validator。

Operating procedure (how to execute tasks)

操作流程(任务执行方式)

When solving a Solana task:
处理Solana任务时:

1. Classify the task layer

1. 对任务层级进行分类

  • UI/wallet/hook layer
  • Client SDK/scripts layer
  • Program layer (+ IDL)
  • Testing/CI layer
  • Infra (RPC/indexing/monitoring)
  • UI/钱包/钩子层
  • 客户端SDK/脚本层
  • 程序层(+ IDL)
  • 测试/CI层
  • 基础设施(RPC/索引/监控)

2. Pick the right building blocks

2. 选择合适的构建模块

  • UI: framework-kit patterns.
  • Scripts/backends: @solana/kit directly.
  • Legacy library present: introduce a web3-compat adapter boundary.
  • High-performance programs: Pinocchio over Anchor.
  • UI:采用framework-kit模式。
  • 脚本/后端:直接使用@solana/kit。
  • 存在遗留库:引入web3-compat适配器边界。
  • 高性能程序:使用Pinocchio而非Anchor。

3. Implement with Solana-specific correctness

3. 确保Solana特有的正确性

Always be explicit about:
  • cluster + RPC endpoints + websocket endpoints
  • fee payer + recent blockhash
  • compute budget + prioritization (where relevant)
  • expected account owners + signers + writability
  • token program variant (SPL Token vs Token-2022) and any extensions
始终明确以下内容:
  • 集群 + RPC端点 + WebSocket端点
  • 费用支付者 + 最新区块哈希
  • 计算预算 + 优先级(相关场景下)
  • 预期账户所有者 + 签名者 + 可写性
  • 代币程序变体(SPL Token vs Token-2022)及任何扩展

4. Add tests

4. 添加测试

  • Unit test: LiteSVM or Mollusk.
  • Integration test: Surfpool.
  • For "wallet UX", add mocked hook/provider tests where appropriate.
  • 单元测试:LiteSVM或Mollusk。
  • 集成测试:Surfpool。
  • 针对“钱包用户体验”,酌情添加模拟钩子/提供者测试。

5. Deliverables expectations

5. 交付物要求

When you implement changes, provide:
  • exact files changed + diffs (or patch-style output)
  • commands to install/build/test
  • a short "risk notes" section for anything touching signing/fees/CPIs/token transfers
实现变更时,需提供:
  • 具体修改的文件 + 差异(或补丁格式输出)
  • 安装/构建/测试命令
  • 针对任何涉及签名/费用/CPI/代币转账的内容,添加简短的“风险说明”部分

Progressive disclosure (read when needed)

渐进式披露(按需阅读)

  • UI + wallet + hooks: frontend-framework-kit.md
  • Kit ↔ web3.js boundary: kit-web3-interop.md
  • Anchor programs: programs-anchor.md
  • Pinocchio programs: programs-pinocchio.md
  • Testing strategy: testing.md
  • IDLs + codegen: idl-codegen.md
  • Payments: payments.md
  • Confidential transfers: confidential-transfers.md
  • Security checklist: security.md
  • Reference links: resources.md
  • UI + 钱包 + 钩子:frontend-framework-kit.md
  • Kit ↔ web3.js边界:kit-web3-interop.md
  • Anchor程序:programs-anchor.md
  • Pinocchio程序:programs-pinocchio.md
  • 测试策略:testing.md
  • IDLs + 代码生成:idl-codegen.md
  • 支付:payments.md
  • 保密转账:confidential-transfers.md
  • 安全检查清单:security.md
  • 参考链接:resources.md