Rent-Free Solana Programs
The Light SDK pays rent-exemption for PDAs, token accounts, and mints. Program logic stays mostly untouched.
| Rent cost (per account) | Solana / SPL | Light SDK |
|---|
| Token account | ~2,000,000 lamports | ~11,000 lamports |
| Avg. DeFi pool |
~$2 | ~
$0.02 |
Workflow
- 1. Clarify intent
- Recommend plan mode, if it's not activated
- Use
AskUserQuestion to resolve blind spots
- All questions must be resolved before execution
- 2. Identify references and skills
- Match task to
domain references below
- Locate relevant documentation and examples
- 3. Write plan file (YAML task format)
- Use
AskUserQuestion for anything unclear — never guess or assume
- Identify blockers: permissions, dependencies, unknowns
- Plan must be complete before execution begins
- 4. Execute
- Use
Task tool with subagents for parallel research
- Subagents load skills via
Skill tool
- Track progress with
TodoWrite
- 5. When stuck: spawn subagent with
Read, Glob, Grep, DeepWiki MCP access and load INLINECODE8
Domain References
references/pinocchio.md |
| Client SDK (LightProgramInterface) |
references/client-sdk.md |
| Testing |
references/testing.md |
| CPI instructions |
references/instructions.md |
| FAQ |
references/faq.md |
| Router integration |
references/router.md |
When to use which
| Criteria | Anchor | Pinocchio |
|---|
| Framework | INLINECODE9 , #[light_program] macro | INLINECODE11 , LightProgramPinocchio derive |
| State struct |
Option<CompressionInfo> +
LightAccount derive |
CompressionInfo (non-optional) +
bytemuck::Pod + Zeroable +
#[repr(C)] |
| Account creation |
#[light_account(init, ...)] attribute or
CreateTokenAccountCpi |
CreateTokenAccountCpi,
CreateMints batch pattern |
| Compress/decompress handlers | Auto-generated by
#[light_program] macro | Route
ProgramAccounts::COMPRESS_ACCOUNTS_IDEMPOTENT etc. in entrypoint |
| Program ID constant | Not needed (macro derives it) |
pub const ID: Pubkey = pubkey_array!(...) +
LIGHT_CPI_SIGNER required |
| Dependencies |
light-sdk,
light-sdk-macros,
light-token,
light-anchor-spl |
light-account-pinocchio,
light-token-pinocchio,
bytemuck |
DeFi integration
For DeFi programs (AMMs, lending, vaults): the Anchor and Pinocchio patterns above apply directly. DeFi-specific references:
| Task | Reference |
|---|
| Router/aggregator integration (cold account loading) | references/router.md |
| LightProgramInterface trait (client SDK for routers) |
references/client-sdk.md |
Hot vs Cold Model
After extended inactivity (multiple epochs without writes), accounts auto-compress to cold state. Programs only interact with hot accounts. Clients load cold accounts back on-chain via create_load_instructions.
| Hot (active) | Cold (inactive) |
|---|
| Storage | On-chain | Compressed |
| Latency |
Normal | +0-200ms |
| Tx size | Normal | +100-2400 bytes |
| CU | Normal | +15k-400k CU |
| Program code | No change | No change |
The hot path has zero overhead.
External References
pinocchio-swap |
| Anchor counter (rent-free PDA) |
basic-macros/counter |
| Pinocchio counter (zero-copy PDA) |
pinocchio/counter |
SDK references
| Package | Link |
|---|
| INLINECODE34 | docs.rs |
| INLINECODE35 |
docs.rs |
|
light-sdk-pinocchio |
docs.rs |
|
light-token |
docs.rs |
|
light-token-pinocchio |
docs.rs |
|
light-account-pinocchio |
docs.rs |
|
light-token-client |
docs.rs |
|
light-client |
docs.rs |
|
light-program-test |
docs.rs |
Security
This skill does not pull, store, or transmit external secrets. It provides code patterns, documentation references, and development guidance only.
- - No credentials consumed. The skill requires no API keys, private keys, or signing secrets.
env: [] is declared explicitly. - User-provided configuration. RPC endpoints, wallet keypairs, and authentication tokens (Privy, wallet adapters) are configured in the user's own application code — the skill only demonstrates how to use them.
- Install source.
npx skills add Lightprotocol/skills installs from the public GitHub repository (Lightprotocol/skills). Verify the source before running. - Subagent scope. This skill may spawn read-only subagents that use
Read, Glob, and Grep to search the local repository. Restrict the working directory to your project. - Audited protocol. Light Protocol smart contracts are independently audited. Reports are published at github.com/Lightprotocol/light-protocol/tree/main/audits.
免租金Solana程序
Light SDK为PDA、代币账户和铸币账户支付免租费用。程序逻辑基本保持不变。
| 租金成本(每个账户) | Solana / SPL | Light SDK |
|---|
| 代币账户 | ~2,000,000 lamports | ~11,000 lamports |
| 平均DeFi池 |
~$2 | ~
$0.02 |
工作流程
- 1. 明确意图
- 推荐计划模式(如果尚未激活)
- 使用AskUserQuestion解决盲点
- 执行前必须解决所有问题
- 2. 识别参考资料和技能
- 将任务匹配到下方的
领域参考资料
- 定位相关文档和示例
- 3. 编写计划文件(YAML任务格式)
- 对任何不明确的内容使用AskUserQuestion——切勿猜测或假设
- 识别阻塞因素:权限、依赖项、未知项
- 执行开始前计划必须完整
- 4. 执行
- 使用带子代理的Task工具进行并行研究
- 子代理通过Skill工具加载技能
- 使用TodoWrite跟踪进度
- 5. 遇到困难时:生成具有Read、Glob、Grep、DeepWiki MCP访问权限的子代理,并加载skills/ask-mcp
领域参考资料
references/pinocchio.md |
| 客户端SDK(LightProgramInterface) |
references/client-sdk.md |
| 测试 |
references/testing.md |
| CPI指令 |
references/instructions.md |
| 常见问题 |
references/faq.md |
| 路由器集成 |
references/router.md |
何时使用哪种模式
| 标准 | Anchor | Pinocchio |
|---|
| 框架 | anchor-lang 0.31,#[light_program]宏 | pinocchio 0.9,LightProgramPinocchio派生 |
| 状态结构体 |
Option
+ LightAccount派生 | CompressionInfo(非可选)+ bytemuck::Pod + Zeroable + #[repr(C)] |
| 账户创建 | #[light_account(init, ...)]属性或CreateTokenAccountCpi | CreateTokenAccountCpi,CreateMints批量模式 |
| 压缩/解压缩处理器 | 由#[lightprogram]宏自动生成 | 在入口点路由ProgramAccounts::COMPRESSACCOUNTS_IDEMPOTENT等 |
| 程序ID常量 | 不需要(宏自动派生) | pub const ID: Pubkey = pubkeyarray!(...) + 需要LIGHTCPI_SIGNER |
| 依赖项 | light-sdk,light-sdk-macros,light-token,light-anchor-spl | light-account-pinocchio,light-token-pinocchio,bytemuck |
DeFi集成
对于DeFi程序(AMM、借贷、金库):上述Anchor和Pinocchio模式直接适用。DeFi特定参考资料:
references/client-sdk.md |
热模型与冷模型
经过长时间不活动(多个纪元无写入)后,账户自动压缩为冷状态。程序仅与热账户交互。客户端通过createloadinstructions将冷账户重新加载到链上。
正常 | +0-200ms |
| 交易大小 | 正常 | +100-2400字节 |
| CU | 正常 | +15k-400k CU |
| 程序代码 | 无变化 | 无变化 |
热路径具有零开销。
外部参考资料
pinocchio-swap |
| Anchor计数器(免租金PDA) | basic-macros/counter |
| Pinocchio计数器(零拷贝PDA) | pinocchio/counter |
SDK参考资料
| 包 | 链接 |
|---|
| light-sdk | docs.rs |
| light-sdk-macros |
docs.rs |
| light-sdk-pinocchio | docs.rs |
| light-token | docs.rs |
| light-token-pinocchio | docs.rs |
| light-account-pinocchio | docs.rs |
| light-token-client | docs.rs |
| light-client | docs.rs |
| light-program-test | docs.rs |
安全性
本技能不拉取、存储或传输外部机密。仅提供代码模式、文档参考和开发指导。