技能 solana-dev
📦

solana-dev

低風險 ⚙️ 外部命令🌐 網路存取📁 檔案系統存取⚡ 包含腳本🔑 環境變數

使用 Anchor 构建和调试 Solana Dapps

构建 Solana 应用程序的开发者难以找到全面的文档和正确的实现模式。本技能提供从钱包集成、智能合约开发、测试框架到部署工作流程的端到端指导。

支援: Claude Codex Code(CC)
📊 70 充足
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「solana-dev」。 Create a staking program that rewards users with tokens for locking their NFTs

預期結果:

质押智能合约的实施计划,包含账户验证、奖励计算逻辑和提款处理器。

正在使用「solana-dev」。 Debug: Transaction simulation failed with error 'instruction consumed too many compute units'

預期結果:

计算预算使用情况分析及优化建议,包括增加计算单元、简化验证和减少账户读取。

安全審計

低風險
v1 • 4/29/2026

This skill is a legitimate Solana developer documentation reference from Solana Foundation. All static findings are false positives - the detected patterns are markdown documentation showing CLI commands, error messages, and code examples, not executable malicious code. The skill provides development tooling references and integrates with official Solana MCP server for documentation search.

28
已掃描檔案
8,277
分析行數
9
發現項
1
審計總數
中風險問題 (2)
Documentation Patterns Misidentified as Executable Code
Static analyzer detected 'Ruby/shell backtick execution' patterns in markdown documentation files. These are documentation showing CLI commands (anchor build, solana-test-validator) and shell examples, not actual code execution. The backtick syntax is used in markdown code blocks to show command examples for developers.
Cryptographic Algorithm References in Documentation
Static analyzer flagged 'weak cryptographic algorithm' patterns in documentation files. These are references to encryption methods (AES, SHA256) and their usage patterns documented for developers, not actual vulnerable cryptographic implementations.
低風險問題 (2)
Network URL References in Documentation
Hardcoded URLs detected in documentation are references to official Solana documentation, RPC endpoints, and developer resources.
Path Traversal Sequences in Migration Documentation
Path traversal patterns like '../' appear in migration documentation showing file path examples during version upgrades.

風險因素

⚙️ 外部命令 (1)
🌐 網路存取 (1)
📁 檔案系統存取 (1)
⚡ 包含腳本
未記錄任何特定位置
🔑 環境變數
未記錄任何特定位置
審計者: claude

品質評分

50
架構
100
可維護性
87
內容
31
社群
76
安全
91
規範符合性

你能建構什麼

构建代币程序

在 Solana 上创建同质化或非同质化代币,包含正确的元数据、铸造权限和冻结条款。

调试交易失败

诊断并解决常见的 Anchor 错误,包括账户冲突、租金问题和签名不匹配。

设置开发环境

配置本地验证器、安装 Anchor 并与钱包提供商集成,以实现快速开发迭代。

試試這些提示

创建基础代币
Create a fungible token on Solana with {TOKEN_NAME} symbol and {DECIMALS} decimals. Include a mint authority and freeze authority.
调试交易错误
Debug this Solana transaction error: {ERROR_MESSAGE}. The transaction was trying to {ACTION} on account {ACCOUNT_ADDRESS}.
实现 CPI 调用
Write a cross-program invocation from {SOURCE_PROGRAM} to call {TARGET_PROGRAM} with {ACCOUNTS} accounts and {DATA} instruction data.
编写程序测试
Write comprehensive tests for {PROGRAM_NAME} using {TESTING_FRAMEWORK}. Include happy path, edge cases, and failure scenarios.

最佳實務

  • 始终通过 findProgramAddress 派生 PDA 进行验证,并检查结果地址是否与预期值匹配
  • 在 Anchor 指令中使用明确的账户排序,并与 IDL 定义顺序保持一致
  • 使用 #[error_code] 属性包含正确的错误类型,以便更好地调试和用户反馈

避免

  • 创建账户时不要跳过租金豁免检查——这会导致交易在 mainnet 上失败
  • 避免硬编码程序 ID——始终从 Anchor 工作区或配置中派生
  • 不要对代币金额使用不安全的算术运算——始终使用安全数学运算来防止溢出漏洞

常見問題

Anchor 和 Pinocchio 有什么区别?
Anchor 提供更高级别的框架,带有派生宏和账户验证。Pinocchio 是更接近原始 BPF 字节码的低级别 SDK。对于大多数程序使用 Anchor,极端优化场景使用 Pinocchio。
如何正确计算程序派生地址?
使用 findProgramAddress 返回的 bump seed 并将其存储在账户中。始终使用存储的 bump 重新派生 PDA 进行验证,以防止欺骗攻击。
为什么我的交易因租金资金不足而失败?
账户需要通过保持最低余额来支付租金豁免。对可写账户使用 SystemAccount,并确保付款人有足够的 SOL 来支付账户大小。
我应该使用哪个测试框架?
LiteSVM 对简单程序速度最快。Surfpool 提供准确的本地验证器模拟。Mollusk 结合两种方法。根据测试复杂度需求选择。
如何安全处理跨程序调用?
始终验证调用程序 ID,验证通过 CPI 传递的所有账户,并在 CPI 调用完成后使用权限降级关闭签名者账户。
mainnet 安全考虑有哪些?
使用带有 multisig 权限的可升级程序,实施暂停功能,添加基于时间的不变量,并始终先在 devnet 和 testnet 上使用真实资产进行测试。