A minimalist decentralized application that allows users to create, read, update, and delete personal journal entries directly on the Solana blockchain.
This project serves as an introductory CRUD application built with the Anchor framework. It demonstrates the fundamental mechanics of allocating space on-chain and securely associating data with a user's wallet without the overhead of complex tokenomics.
- Write: Users can publish a new journal entry with a title and a message.
- Read: Users can fetch and display all their on-chain entries.
- Edit: Users can modify the text of an existing entry.
- Delete: Users can close the account to delete the entry and reclaim their storage rent.
- Smart Contract: Rust, Solana, Anchor Framework
- Environment: VSCode (recommended with
rust-analyzer)
Before running this project, ensure you have the following installed on your machine:
git clone <your-repo-url>
cd solana-journal
yarn installThis will compile the Rust smart contract and generate the necessary IDL files.
anchor buildBoot up a local Solana test validator and execute the TypeScript test suite against the compiled program to verify the CRUD logic.
anchor testsolana-journal/
├── programs/
│ └── solana-journal/
│ └── src/
│ └── lib.rs # Core smart contract logic
├── tests/
│ └── solana-journal.ts # TypeScript testing suite
├── Anchor.toml # Anchor workspace configuration
└── README.md
programs/solana-journal/src/lib.rs- The core smart contract logic written in Rust.tests/solana-journal.ts- The TypeScript testing suite simulating the creation, editing, and deletion of journal entries.Anchor.toml- The Anchor workspace configuration and network settings.
await program.methods
.createEntry(title, message)
.accounts({
entry: entryAccount.publicKey,
owner: wallet.publicKey,
})
.rpc();const entries = await program.account.journalEntry.all([
{
memcmp: {
offset: 8,
bytes: wallet.publicKey.toBase58(),
}
}
]);await program.methods
.updateEntry(newTitle, newMessage)
.accounts({
entry: entryAccount.publicKey,
owner: wallet.publicKey,
})
.rpc();await program.methods
.deleteEntry()
.accounts({
entry: entryAccount.publicKey,
owner: wallet.publicKey,
})
.rpc();- Start a local Solana test validator:
solana-test-validator- Deploy the program to the local network:
anchor deploy- Run tests:
anchor test --skip-local-validator- Configure Solana CLI to use devnet:
solana config set --url devnet- Airdrop SOL for deployment costs:
solana airdrop 2- Deploy to devnet:
anchor deploy --provider.cluster devnetContributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is MIT licensed.
- Anchor Framework - The framework that powers this dApp
- Solana - The blockchain platform
- The Solana developer community for excellent documentation and support
Built with ❤️ on Solana