NoteChain is a secure, decentralized note-taking application built on the Solana blockchain. Designed to eliminate the need for centralized databases, this project leverages the speed and low fees of Solana to provide users with a fully on-chain, censorship-resistant platform for personal and collaborative notes.
The smart contract (program) is written in Rust using the Anchor framework, providing a robust backend that seamlessly integrates with a modern Next.js/React frontend.
Traditional note-taking apps rely on central servers, leaving user data vulnerable to breaches or platform lock-in. NoteChain solves this by giving users absolute cryptographic ownership of their data. Every note, user profile, and sharing permission is strictly governed by smart contract logic and validated via the user's wallet signature.
This project demonstrates advanced Solana blockchain development concepts, including Program Derived Addresses (PDAs), secure state management,secure multi-user access,and on-chain data ownership.
- Wallet-Linked User Profiles: Users initialize a unique on-chain profile mapped directly to their Solana wallet address, tracking their total note count and identity.
- 100% On-Chain Storage: Full CRUD (Create, Read, Update, Delete) functionality where note content is stored securely on the Solana ledger.
- Secure Collaboration (The "Shared with Friend" Feature): A standout collaborative feature that allows a note owner to grant specific edit permissions to a friend's wallet. The collaborator can update the note seamlessly without altering the original ownership rights.
- Frontend-Ready: Designed with highly optimized data structures to be easily consumed by a Next.js (TypeScript) client.
- Smart Contract / Backend: Rust, Anchor Framework
- Blockchain Network: Solana (Devnet)
- Testing & Scripting: TypeScript, Mocha, Chai,
@coral-xyz/anchor - Target Client-Side: Next.js, React, Tailwind CSS (Dark Theme UI optimized)
Instead of traditional database tables, NoteChain uses Program Derived Addresses (PDAs) to deterministically locate and manage state. This ensures O(1) lookup times and strict data isolation.
UserProfilePDA:- Seeds:
[b"user_profile", wallet_address] - Role: Acts as the root account for a user. Stores their chosen username and acts as an auto-incrementing counter (
note_count) to assign unique IDs to new notes.
- Seeds:
NotePDA:- Seeds:
[b"note", wallet_address, note_id] - Role: The core data structure. Holds the note's title, content, and the public key of the original author.
- Seeds:
SharedAccessPDA:- Seeds:
[b"share", note_pda, friend_wallet_address] - Role: A decentralized permission slip. It cryptographically binds a specific note to a specific collaborator's wallet, enabling secure multi-user editing.
- Seeds:
Security is a primary focus of this smart contract. The program heavily utilizes Anchor's constraint system to prevent unauthorized access and malicious data manipulation:
- Signer Validation: Operations like creating, updating, or deleting notes strictly require the
signerto match the note'sauthority. has_oneConstraints: Automatically verifies that the authority account passed in the transaction exactly matches the authority stored inside the Note or User Profile.- Custom Error Handling: Implements explicit
ErrorCode::UnauthorizedAccessto cleanly reject invalid operations (e.g., a user trying to edit a note they don't own). - Secure Account Closing: The
delete_noteinstruction safely closes the PDA account and refunds the rent lamports back to the original signer, preventing stranded data.
The test suite covers the full workflow:
- user creation
- note creation
- note updates
- sharing notes
- collaborator updates
- note deletion
Tests simulate real multi-user behavior, including shared access.
Follow these steps to run the blockchain backend and test suite locally.
- Rust
- Solana CLI
- Anchor CLI
- Node.js & Yarn (or npm)
- Clone the repository
git clone <your-repository-url> cd notechain
- Install dependencies
npm install
- Build the Anchor program
anchor build
- Start local Solana validator
solana-test-validator
- Deploy the program
anchor deploy
- Run tests
anchor test
Piyush Raj
This project is licensed under the MIT License.