Skip to content

Breedar/PayVault

Repository files navigation

PayVault

Unlock cash flow from unpaid invoices — instantly, on-chain.

PayVault is a decentralized invoice factoring protocol that lets small and medium businesses tokenize their unpaid invoices and sell them to global liquidity providers at a discount. Built on Soroban smart contracts, PayVault removes banks from the equation and gives African SMEs direct access to working capital.


The Problem

Small businesses across emerging markets are owed billions in unpaid invoices at any given time. Traditional invoice factoring is slow, expensive, and gatekept by banks that charge 5–15% fees with weeks of processing. For a business in Lagos waiting on payment from a client in Nairobi, this delay can be fatal.

How PayVault Works

Supplier creates invoice → Invoice is tokenized on-chain → Liquidity providers bid on the invoice
→ Supplier receives discounted payment instantly → Buyer pays the original amount at maturity
→ Liquidity provider earns the spread
  1. Invoice Submission — A supplier uploads invoice details (amount, due date, buyer info) and mints a tokenized representation on the Soroban contract.
  2. Risk Assessment — On-chain reputation scores and historical payment data determine a risk tier for the invoice.
  3. Marketplace Auction — Liquidity providers browse available invoices and place bids, competing on discount rates.
  4. Instant Settlement — Once a bid is accepted, the supplier receives USDC immediately. The smart contract holds the invoice token until the buyer pays at maturity.
  5. Maturity & Payout — When the buyer settles, the liquidity provider receives the full invoice amount. The spread between the discounted price and the face value is their profit.

Architecture

┌─────────────────────────────────────────────────────┐
│                    Frontend (Next.js)                │
│         Dashboard · Invoice Upload · Marketplace     │
└──────────────────────┬──────────────────────────────┘
                       │
                       ▼
┌─────────────────────────────────────────────────────┐
│                  Backend API (NestJS)                │
│     Auth · Invoice Validation · Risk Engine · KYB    │
└──────────────────────┬──────────────────────────────┘
                       │
          ┌────────────┼────────────┐
          ▼            ▼            ▼
   ┌────────────┐ ┌─────────┐ ┌──────────────┐
   │  Soroban    │ │ PostgreSQL│ │  Anchor      │
   │  Contracts  │ │ Database │ │  Integration │
   │             │ │          │ │  (On/Off     │
   │ • Invoice   │ │ • Users  │ │   Ramp)      │
   │   Token     │ │ • KYB    │ │              │
   │ • Escrow    │ │ • History│ │              │
   │ • Auction   │ │          │ │              │
   │ • Reputation│ │          │ │              │
   └────────────┘ └─────────┘ └──────────────┘

Smart Contracts

Contract Purpose
invoice_token Mints a unique token representing each invoice with metadata (amount, due date, buyer, risk tier)
escrow_vault Holds USDC from liquidity providers until invoice maturity or default resolution
auction_engine Manages the bidding process with time-weighted Dutch auction mechanics
reputation_registry Tracks on-chain payment history for buyers and suppliers to compute trust scores

Tech Stack

  • Smart Contracts — Rust / Soroban SDK
  • Frontend — Next.js 14, TypeScript, Tailwind CSS
  • Backend — NestJS, TypeORM, PostgreSQL
  • Authentication — JWT with wallet signature verification
  • Payments — USDC on Stellar, Anchor protocol for fiat on/off-ramps

Key Features

  • Instant Liquidity — Suppliers get paid in minutes, not weeks
  • Competitive Rates — Open marketplace drives discount rates down vs. traditional factoring
  • Transparent Risk — On-chain reputation scores visible to all participants
  • Multi-Currency Settlement — Accept invoices in local currencies, settle in USDC
  • Non-Custodial — Funds are held in smart contracts, not by PayVault
  • Compliance Ready — Built-in KYB verification for businesses

Getting Started

Prerequisites

  • Rust 1.77+ with wasm32-unknown-unknown target
  • Node.js 20+
  • PostgreSQL 15+
  • Soroban CLI

Installation

# Clone the repository
git clone https://github.com/your-org/payvault.git
cd payvault

# Install contract dependencies
cd contracts
cargo build --target wasm32-unknown-unknown --release

# Install frontend dependencies
cd ../frontend
npm install

# Install backend dependencies
cd ../backend
npm install

# Set up environment variables
cp .env.example .env

# Run database migrations
npm run migration:run

# Start development servers
npm run dev

Environment Variables

DATABASE_URL=postgresql://user:pass@localhost:5432/payvault
SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
SOROBAN_NETWORK_PASSPHRASE="Test SDF Network ; September 2015"
JWT_SECRET=your-secret-key
ANCHOR_API_URL=https://anchor.example.com

Project Structure

payvault/
├── contracts/
│   ├── invoice_token/       # Invoice NFT minting
│   ├── escrow_vault/        # Payment escrow logic
│   ├── auction_engine/      # Bidding mechanics
│   └── reputation_registry/ # Trust score tracking
├── frontend/
│   ├── app/                 # Next.js app router pages
│   ├── components/          # React components
│   ├── hooks/               # Custom hooks for contract interaction
│   └── lib/                 # Utilities and API clients
├── backend/
│   ├── src/
│   │   ├── modules/         # NestJS feature modules
│   │   ├── entities/        # TypeORM entities
│   │   └── services/        # Business logic
│   └── migrations/          # Database migrations
└── docs/                    # Documentation

Roadmap

  • Core smart contract architecture
  • Invoice tokenization contract
  • Escrow and auction contracts
  • Frontend dashboard MVP
  • Backend API and risk engine
  • Testnet deployment
  • KYB integration
  • Anchor on/off-ramp integration
  • Mainnet launch
  • Mobile app

Contributing

We welcome contributions from the community. Please read our CONTRIBUTING.md for guidelines on how to get started.

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

License

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


PayVaultBecause your invoices shouldn't be IOUs.

About

Decentralized invoice factoring protocol built on Soroban smart contracts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors