Here's a suggested README.md
template for your repository. It includes an overview of the project structure, descriptions of each program, and usage instructions.
This repository contains various Solana programs designed for different functionalities, including escrow management, fundraising, token vaults, and assembly-level implementations.
This project demonstrates advanced use of the Solana blockchain for financial and system-level programming. Each program in this repository serves a distinct purpose:
- Escrow: Handles secure transactions between two parties.
- Fundraiser: Enables crowdfunding with token contributions.
- Vault: Implements optimized storage for tokens, including native Solana assembly.
- SBPF-Close: An example of Solana BPF (Berkeley Packet Filter) programming with low-level operations.
.
├── escrow/ # Escrow program for secure transactions
├── fundraiser/ # Crowdfunding program
├── vault/ # Token vault implementations with multiple features
├── sbpf-close/ # Example of SBPF-level programming
├── Cargo.toml # Root cargo manifest
├── README.md # Repository documentation
- Location:
escrow/
- Description: A program to handle secure transactions between two parties. It includes instructions for creating, funding, and executing escrow agreements.
- Entrypoint:
process_instruction
make.rs
: Initiates an escrow.take.rs
: Completes an escrow transaction.refund.rs
: Handles refunds in case of disputes.
- Location:
fundraiser/
- Description: A crowdfunding platform where contributors can support fundraisers using SPL tokens. It includes checks for fundraising goals and refund mechanisms.
- Entrypoint:
process_instruction
initialize.rs
: Sets up a new fundraiser.contribute.rs
: Accepts contributions to the fundraiser.check.rs
: Verifies contributions against goals.refund.rs
: Processes refunds for incomplete fundraisers.
Unit tests for the fundraiser are located in the tests
module. Example tests include:
contribute_test.rs
refund_test.rs
- Location:
vault/
- Description: Implements token vault functionality with different levels of optimization:
- Based: Standard implementation.
- Optimized: Performance-tuned version.
- Native: Low-level native Solana implementation.
based.rs
: Basic vault implementation.optimized.rs
: Optimized storage and retrieval.native.rs
: Native assembly-level implementation.
- Location:
sbpf-close/
- Description: A program written in SBPF (Solana BPF) for low-level account operations.
- Entrypoint:
sbpf_close.s
This program demonstrates advanced techniques like closing accounts and transferring lamports in assembly.
- Rust and Cargo installed (Installation Guide).
- Solana CLI tools installed (Installation Guide).
Run the following command in the root directory to build all programs:
cargo build-bpf
Use the Solana CLI to deploy a program:
solana program deploy ./path/to/program.so
Run unit tests for a specific program:
cargo test --manifest-path ./program-name/Cargo.toml
Each program includes its own unit tests. Navigate to the program directory and run:
cargo test
To test the fundraiser program:
cd fundraiser
cargo test-sbf