Create a Program with Compressed PDAs
Overview to compressed PDA core features and guide for program development.
Compressed PDAs provide full functionality of accounts at PDAs, without per-account rent cost.
100-byte PDA
~ 0.0016 SOL
~ 0.00001 SOL
160x
Compressed PDAs are derived using a specific program address and seed, like regular PDAs. Custom programs invoke the to create and update accounts, instead of the System program.
Compressed PDAs at a Glance
Rent free PDAs
Create accounts at program-derived addresses without upfront rent exempt balance.
Full PDA Functionality
Deterministic seed generation and program ownership.
Composable
CPI support between compressed and regular PDAs.
Start Building
Developing with compressed PDAs works similar to regular PDAs and involves minimal setup:
Prerequisite Setup
Install the Light CLI:
npm -g i @lightprotocol/zk-compression-cli
### verify installation
light --version
Initialize Your Program
light init testprogram
This initializes an anchor program with a basic counter program template using compressed accounts with all required dependencies.
Build and Test
Now cd testprogram
and run:
anchor build
# Success: Finished `release` profile [optimized] target(s), after compiling.
# Note: Stack offset warnings are expected and don't prevent compilation
cargo test-sbf
# Success: test result: ok. 1 passed; 0 failed; 0 ignored
Common Errors
More Examples
Counter Program
The counter program implements a compressed account lifecycle (create, increment, decrement, reset, close):
counter/anchor - Anchor program with Rust and TypeScript tests
counter/native - Native Solana program with light-sdk and Rust tests.
counter/pinocchio - Pinocchio program with light-sdk-pinocchio and Rust tests.
Create and Update Program
create-and-update - Create a new compressed account and update an existing compressed account with a single validity proof in one instruction.
Solana vs compressed accounts comparison Program
account-comparison - Compare compressed vs regular Solana accounts.
Next Steps
Get an overview of the SDKs for program development with ZK Compression.
Program DevelopmentLast updated