Skip to content

mdsaad31/ChainPe

Repository files navigation

ChainPe - Solana Subscription Management Platform

ChainPe Logo

Decentralized Subscription Payments on Solana

Manage your digital subscriptions with crypto payments, smart contracts, and full transparency.

🚀 Features

  • 🔗 Wallet Integration - Connect with Phantom, Solflare, or Backpack wallets
  • 💳 Multi-Token Support - Pay with USDC, SOL, or USDT
  • 🔒 Escrow System - Funds are securely held in smart contract escrow
  • ⏱️ Automated Payments - Set-and-forget subscription billing
  • 📊 Analytics Dashboard - Track spending, subscriptions, and savings
  • 🎨 Beautiful UI - Modern dark theme with smooth animations

📦 Tech Stack

  • Frontend: Next.js 14, React, TypeScript, Tailwind CSS
  • Animations: Framer Motion
  • Blockchain: Solana, Anchor Framework
  • Wallet: @solana/wallet-adapter-react
  • State Management: Zustand, React Query
  • Forms: React Hook Form, Zod

🛠️ Getting Started

Prerequisites

  • Node.js 18+ and pnpm/npm/yarn
  • Rust and Cargo (for smart contract development)
  • Solana CLI tools
  • Anchor CLI

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/chainpe.git
    cd chainpe
  2. Install dependencies

    npm install
    # or
    pnpm install
  3. Set up environment variables

    cp .env.example .env.local
    # Edit .env.local with your configuration
  4. Run the development server

    npm run dev
  5. Open your browser Navigate to http://localhost:3000

Smart Contract Deployment

  1. Build the Anchor program

    cd programs
    anchor build
  2. Deploy to devnet

    anchor deploy --provider.cluster devnet
  3. Update the program ID

    • Copy the program ID from the deployment output
    • Update NEXT_PUBLIC_PROGRAM_ID in .env.local
    • Update declare_id! in programs/chainpe/src/lib.rs
    • Update Anchor.toml with the new program ID

📁 Project Structure

chainpe/
├── programs/                 # Anchor smart contracts
│   └── chainpe/
│       └── src/
│           └── lib.rs       # Main program logic
├── src/
│   ├── app/                 # Next.js App Router pages
│   │   ├── page.tsx         # Landing page
│   │   ├── dashboard/       # User dashboard
│   │   ├── services/        # Browse services
│   │   ├── transactions/    # Transaction history
│   │   ├── analytics/       # Spending analytics
│   │   ├── settings/        # User settings
│   │   └── api/             # API routes
│   ├── components/          # React components
│   │   ├── layout/          # Navbar, Footer
│   │   ├── ui/              # Reusable UI components
│   │   ├── services/        # Service-related components
│   │   └── subscriptions/   # Subscription components
│   ├── hooks/               # Custom React hooks
│   ├── lib/                 # Utilities and constants
│   │   └── anchor/          # Anchor program integration
│   ├── stores/              # Zustand state stores
│   └── types/               # TypeScript types
├── public/                  # Static assets
└── tailwind.config.ts       # Tailwind configuration

🎨 Design System

Colors

Color Hex Usage
Background #0B0F14 Main background
Surface #141A22 Cards, modals
Primary #14F195 Solana green, CTAs
Secondary #8B5CF6 Violet accents
Success #22C55E Success states
Warning #F59E0B Warnings
Error #EF4444 Errors

Typography

  • Headings: Space Grotesk
  • Body: Inter
  • Code: JetBrains Mono

🔐 Smart Contract

The ChainPe program includes the following instructions:

Instruction Description
initialize_subscription Create a new subscription with escrow
execute_billing_cycle Process a due payment (cron job)
cancel_subscription Cancel and refund remaining escrow
fund_escrow Add more funds to escrow
pause_subscription Temporarily pause payments
resume_subscription Resume a paused subscription

Account Structure

pub struct SubscriptionAccount {
    pub subscriber: Pubkey,
    pub service_provider: Pubkey,
    pub service_id: String,
    pub payment_amount: u64,
    pub billing_interval: i64,
    pub next_execution: i64,
    pub escrow_balance: u64,
    pub total_payments_made: u32,
    pub status: SubscriptionStatus,
    pub created_at: i64,
    pub bump: u8,
}

🚀 Deployment

Frontend (Vercel)

  1. Connect your GitHub repository to Vercel
  2. Configure environment variables
  3. Deploy!

Smart Contract (Mainnet)

# Switch to mainnet
solana config set --url mainnet-beta

# Deploy
anchor deploy --provider.cluster mainnet

📄 API Routes

Endpoint Method Description
/api/subscriptions GET Get user subscriptions
/api/subscriptions POST Subscription actions
/api/cron/billing POST Execute billing cycles

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments


Built with ❤️ for the Solana ecosystem

TwitterDiscordDocumentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors