Skip to content

mdsaad31/ChainPe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

Twitter β€’ Discord β€’ Documentation

About

Decentralized subscription payment platform on Solana supporting recurring billing in USDC, SOL, and USDT. Smart contracts written in Rust using the Anchor framework implement an escrow-based billing cycle. Multi-wallet integration (Phantom, Solflare, Backpack) with a Next.js analytics dashboard.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors