โ† Writing

๐Ÿ“ฆ On-Chain Key-Value Storage

2025-04-09 rust ยท solana ยท anchor ยท project


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.


๐Ÿ“š GitHub Repository

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:


๐Ÿงฐ Stack & Tools


โœจ Features

  1. Send Arbitrary Data to the Blockchain

    • Insert a value associated with a custom key.
  2. Update Stored Data by Key

    • Modify entries via a transaction that targets a specific key.
  3. Simple Chain Storage Pattern

    • Uses Solana accounts to persist user-defined values.
  4. 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


๐Ÿ“„ License

This project is licensed under the MIT License โ€” free for personal and commercial use.