AgentSkillsCN

anchor

Solana 程序的 Anchor 框架——包含程序结构、PDA、CPI、IDL、错误处理、事件机制、零拷贝技术、约束条件、账户类型,以及面向代理驱动式工具的 CLI。

SKILL.md
--- frontmatter
name: anchor
description: Anchor framework for Solana programs — program structure, PDAs, CPI, IDL, errors, events, zero-copy, constraints, account types, and CLI for agent-driven tooling.
metadata:
  author: hairy
  version: "2026.2.9"
  source: Generated from https://github.com/coral-xyz/anchor, scripts located at https://github.com/antfu/skills

Skill is based on Anchor v0.32.1, generated 2026-02-09.

Concise reference for building Solana programs with Anchor: macros, accounts, PDAs, CPI, IDL, custom errors, events, zero-copy, constraints, account types, and CLI.

Core References

TopicDescriptionReference
Program Structuredeclare_id, #[program], #[derive(Accounts)], #[account], Contextcore-program-structure
PDAseeds, bump, init, IDL/client resolution, PDA signercore-pda
CPICpiContext, transfer, PDA signer, invoke/invoke_signedcore-cpi
IDLInstructions, accounts, discriminators, client usagecore-idl

Features

TopicDescriptionReference
Custom Errorserror_code, err!, require! macros, client handlingfeatures-errors
Eventsemit!, emit_cpi!, #[event], addEventListener, event-cpifeatures-events
Zero-CopyAccountLoader, #[account(zero_copy)], load/load_mut/load_initfeatures-zero-copy

References

TopicDescriptionReference
Account Constraintssigner, mut, init, seeds/bump, has_one, address, ownerreferences-account-constraints
Account TypesAccount, Signer, Program, AccountLoader, Interface typesreferences-account-types
CLIbuild, deploy, test, idl, keys, account, expand, upgrade, verifyreferences-cli