Introduction
@lightprotocol/stateless.js is the core JavaScript SDK for building applications on Light Protocol. It provides a comprehensive API for working with compressed accounts, managing state trees, and interacting with the Light system program.
Installation
npm
yarn
pnpm
Package Information
Version
0.23.0-beta.8
License
Apache-2.0
Quick Start
Creating an RPC Connection
The SDK provides a custom RPC client that extends Solana’s Connection with compression-specific methods:Compressing Lamports
Compress SOL into a compressed account to save on rent:Transferring Compressed Lamports
Transfer compressed SOL between accounts:Decompressing Back to SOL
Decompress back to regular SOL:Core Concepts
State Trees
Compressed accounts are stored in Merkle trees. The SDK automatically manages tree selection:Validity Proofs
When spending compressed accounts, you need validity proofs:Key Features
Account Compression
- Rent-free accounts: Store account state in Merkle trees instead of on-chain accounts
- Zero-knowledge proofs: Prove account validity without revealing full state
- Batched operations: Multiple account operations in a single transaction
RPC Methods
The SDK provides comprehensive RPC methods for querying compressed accounts:getCompressedAccount()- Fetch a single compressed accountgetCompressedAccountsByOwner()- Get all accounts owned by a public keygetCompressedBalance()- Query compressed SOL balancegetValidityProof()- Request ZK proofs for transactions
Utility Functions
- BN254 field element helpers for working with account hashes
- Transaction building utilities
- State tree selection algorithms
- Proof formatting and validation
TypeScript Support
The SDK is written in TypeScript with full type definitions:Browser Support
The package supports both Node.js and browser environments:Next Steps
Compressed Accounts
Learn how to work with compressed accounts
RPC Methods
Explore all available RPC methods
Compressed Tokens
Build with compressed SPL tokens
API Reference
Full TypeScript API documentation