π¦ On-Chain Key-Value Storage
A Solana smart contract project that demonstrates how to send, store, and update data on-chain using keys. Built with Rust and the Anchor framework.
This project explores how to interact with a Solana program by writing and updating user-defined data directly on-chain. It simulates a simple βfavoritesβ manager β where users can send strings or numbers to the chain, associate them with a unique key, and later update those entries.
A great starting point for:
- Understanding persistent on-chain state
- Managing user-specific data using derived accounts
- Creating decentralized CRUD-style apps
π§° Stack & Tools
- π¦ Rust (Solana smart contract logic)
- β Anchor (framework for Solana programs)
- π§ͺ Local test validator
- π§ͺ Rust unit/integration tests
β¨ Features
-
Send Arbitrary Data to the Blockchain
- Insert a value associated with a custom key.
-
Update Stored Data by Key
- Modify entries via a transaction that targets a specific key.
-
Simple Chain Storage Pattern
- Uses Solana accounts to persist user-defined values.
-
Full Test Coverage
- Rust-based tests validate program logic locally.
π Getting Started
1. π§ͺ Start Local Solana Validator
Spin up a local blockchain testnet:
solana-test-validator
2. π Build and Deploy
Compile and deploy the Anchor program:
anchor build && anchor deploy
3. π Add Wallet
Set your Solana CLI wallet path:
export ANCHOR_WALLET=~/.config/solana/id.json
4. β Run Tests
Ensure everything works as expected with:
cargo test
5. π View Transactions
Access the local explorer to track activity: http://localhost:8899
π§ Use Cases & Ideas
- β Store favorite quotes, URLs, or topics by key
- π§Ύ Use it as a base for decentralized note-taking or bookmarking
- π Extend it with access control and per-user namespaces
π License
This project is licensed under the MIT License β free for personal and commercial use.