What Changes
If you use Anchor instead of Pinocchio, see Program Integration.
Agent skill
Agent skill
Use the light-sdk agent skill to build rent-free DeFi programs:For orchestration, install the general skill:
- Claude Code
- Cursor
- Any Agent
Add the marketplace and install:
Complete pinocchio Swap reference implementation: pinocchio-swap
- Guide
- AI Prompt
Step 1: Dependencies
Step 2: State Struct
Addcompression_info field and derive LightPinocchioAccount:Step 3: Program Enum
Declare your account types with their seed schemas:LightAccountVariant enum used by the client SDK.Step 4: Entrypoint
Dispatch the generated handlers in your entrypointStep 5: Init Handler
Update your init instruction. Uselight_token_pinocchio CPI builders to create rent-free token accounts.- Create Token Account
- Create Mint
Full Initialize Processor
Full Initialize Processor
Client SDK
ImplementLightProgramInterface so clients can detect cold accounts and build load instructions.
Example: LightProgramInterface Implementation
Example: LightProgramInterface Implementation
Testing
Example: Full Lifecycle Test
Example: Full Lifecycle Test
How it works
The SDK pays the rent-exemption cost. After extended inactivity, cold accounts auto-compress. Your program only ever interacts with hot accounts. Clients can safely load cold accounts back into the onchain Solana account space when needed viacreate_load_instructions.
Under the hood, clients use AccountInterface - a superset of Solana’s
Account that unifies hot and cold state. See Router Integration
for details.
Existing programs
If you want to migrate your program to rent-free accounts and would like hands-on support, join our tech Discord, or email us.FAQ
Do I have to manually handle compression/decompression?
Do I have to manually handle compression/decompression?
No.
LightProgramPinocchio generates the handlers. Simply add the generated handlers to your entrypoint, and update your init instruction.How does it prevent re-init attacks?
How does it prevent re-init attacks?
When creating an
account for the first time, the SDK provides a proof that the account doesn’t
exist in the cold address space. The SVM already verifies this for the onchain
space. Both address spaces are checked before creation, preventing re-init
attacks, even if the account is currently cold.
Who triggers compression?
Who triggers compression?
Miners (Forester nodes) compress accounts that have been inactive for an extended period of time (when their virtual rent balance drops below threshold).
In practice, having to load cold accounts should be rare. The common path (hot) has no extra overhead and does not increase CU or txn size.
How is the SDK able to sponsor rent exemption?
How is the SDK able to sponsor rent exemption?
When accounts compress after extended inactivity, the on-chain rent-exemption is released back
to the rent sponsor. This creates a revolving lifecycle: active “hot” accounts hold a
rent-exempt lamports balance, inactive “cold” accounts release it back. The
rent sponsor must be derived from the program owner. For all mint, ATA, and
token accounts, the Light Token Program is the rent sponsor. For your own program-owned PDAs, the SDK derives a rent sponsor address automatically.
Do rent-free accounts increase CU?
Do rent-free accounts increase CU?
Hot path (e.g. swap, deposit, withdraw): No. Active accounts do not add CU overhead to your instructions.First time init + loading cold accounts: Yes, adds up to 15k-400k CU,
depending on number and type of accounts being initialized or loaded.