Skip to content

Latest commit

 

History

History
146 lines (107 loc) · 4.2 KB

README.md

File metadata and controls

146 lines (107 loc) · 4.2 KB

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.


Solana Programs Repository

This repository contains various Solana programs designed for different functionalities, including escrow management, fundraising, token vaults, and assembly-level implementations.

Table of Contents


Overview

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.

Repository Structure

.
├── 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

Programs

Escrow

  • 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

Instructions

  • make.rs: Initiates an escrow.
  • take.rs: Completes an escrow transaction.
  • refund.rs: Handles refunds in case of disputes.

Fundraiser

  • 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

Instructions

  • 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.

Tests

Unit tests for the fundraiser are located in the tests module. Example tests include:

  • contribute_test.rs
  • refund_test.rs

Vault

  • 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.

Modules

  • based.rs: Basic vault implementation.
  • optimized.rs: Optimized storage and retrieval.
  • native.rs: Native assembly-level implementation.

SBPF-Close

  • 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.


Usage

Prerequisites

Build

Run the following command in the root directory to build all programs:

cargo build-bpf

Deploy

Use the Solana CLI to deploy a program:

solana program deploy ./path/to/program.so

Run Tests

Run unit tests for a specific program:

cargo test --manifest-path ./program-name/Cargo.toml

Building and Testing

Testing Individual Programs

Each program includes its own unit tests. Navigate to the program directory and run:

cargo test

Example

To test the fundraiser program:

cd fundraiser
cargo test-sbf