Skip to content

barnazaka/PrivCredit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrivCredit — Confidential Private Credit Marketplace

Decentralized private credit for SMEs using iExec Nox Confidential Computing and ERC-7984 Confidential Tokens on Arbitrum Sepolia.


Table of Contents

  1. Project Overview
  2. Architecture
  3. Prerequisites
  4. Smart Contract Setup & Deployment
  5. Frontend Setup
  6. Testing the Flows
  7. Deployed Contract Addresses
  8. Project Structure

Project Overview

PrivCredit is a decentralized platform where:

  • Originators tokenize private credit instruments (invoices, short-term SME loans) as PCT (PrivCreditToken) — an ERC-7984 Confidential Token.
  • Lenders supply liquidity to credit pools privately. Their position sizes are never exposed on-chain.
  • Auditors (the contract owner in this demo) can selectively decrypt balances for compliance — without exposing other participants.

Why Confidential Tokens?

Traditional DeFi lending exposes all position sizes publicly. For institutional private credit, this is unacceptable:

  • Competitors can see your exposure
  • Front-running is possible
  • Regulatory selective disclosure is impossible

ERC-7984 + iExec Nox solves this by encrypting balances and transfer amounts inside a Trusted Execution Environment (TEE).


Architecture

┌─────────────────────────────────────────────────────────┐
│                    Arbitrum Sepolia                      │
│                                                         │
│  ┌─────────────────────┐    ┌────────────────────────┐  │
│  │  PrivCreditToken    │    │   PrivCreditPool       │  │
│  │  (ERC-7984 / PCT)   │───▶│   (Lending Pool)       │  │
│  │                     │    │                        │  │
│  │  - encryptedBalance │    │  - deposit(encrypted)  │  │
│  │  - confidentialXfer │    │  - Event: Deposited    │  │
│  │  - auditBalance()   │    │    (address only, NO   │  │
│  └─────────────────────┘    │     amount emitted)    │  │
│                             └────────────────────────┘  │
└─────────────────────────────────────────────────────────┘
         ▲                              ▲
         │                              │
┌────────┴──────────────────────────────┴────────┐
│              iExec Nox TEE Layer               │
│  - FHE encryption of amounts before tx         │
│  - Selective decryption for auditor only       │
│  - No plaintext ever hits the chain            │
└────────────────────────────────────────────────┘
         ▲
         │
┌────────┴────────────────────────────────────────┐
│           Next.js Frontend (Wagmi + RainbowKit) │
│  - Connect wallet (Arbitrum Sepolia)            │
│  - Mint PCT (originator flow)                   │
│  - Confidential transfer (hidden amount)        │
│  - Deposit to pool (position stays private)     │
└─────────────────────────────────────────────────┘

Prerequisites


Smart Contract Setup & Deployment

1. Install dependencies

cd contracts
npm install

2. Configure environment

cp .env.example .env

Edit .env:

PRIVATE_KEY=your_deployer_wallet_private_key_here
ARBITRUM_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
ARBISCAN_API_KEY=your_arbiscan_api_key_here   # optional

3. Compile contracts

npm run compile

Expected output:

Compiled 2 Solidity files successfully

4. Deploy to Arbitrum Sepolia

npm run deploy:sepolia

Expected output:

🚀 Deploying PrivCredit contracts to arbitrumSepolia
──────────────────────────────────────────────────
📬 Deployer address: 0xYourAddress

📄 Deploying PrivCreditToken (PCT)...
✅ PrivCreditToken deployed at: 0xABC...

🏦 Deploying PrivCreditPool...
✅ PrivCreditPool deployed at: 0xDEF...

💰 Minting initial PCT to deployer (for demo)...
✅ Minted 10,000 PCT to 0xYourAddress

──────────────────────────────────────────────────
🎉 Deployment complete!
NEXT_PUBLIC_PCT_ADDRESS=0xABC...
NEXT_PUBLIC_POOL_ADDRESS=0xDEF...

Copy the two addresses — you will need them for the frontend.

5. Verify contracts (optional but recommended)

Verification happens automatically during deploy if ARBISCAN_API_KEY is set.

Manual verification:

npx hardhat verify --network arbitrumSepolia 0xYourPCTAddress
npx hardhat verify --network arbitrumSepolia 0xYourPoolAddress "0xYourPCTAddress" "PrivCredit SME Invoice Pool" "Invoice Financing"

Frontend Setup

1. Install dependencies

cd frontend
npm install

2. Configure environment

cp .env.local.example .env.local

Edit .env.local:

NEXT_PUBLIC_PCT_ADDRESS=0xYourPrivCreditTokenAddress
NEXT_PUBLIC_POOL_ADDRESS=0xYourPrivCreditPoolAddress
NEXT_PUBLIC_CHAIN_ID=421614
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id

3. Run locally

npm run dev

Open http://localhost:3000

4. Deploy to Vercel

Option A — Vercel CLI (recommended)

npm install -g vercel
vercel login
vercel --prod

When prompted, add environment variables:

  • NEXT_PUBLIC_PCT_ADDRESS
  • NEXT_PUBLIC_POOL_ADDRESS
  • NEXT_PUBLIC_CHAIN_ID = 421614
  • NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID

Option B — Vercel Dashboard

  1. Push your frontend/ folder to a GitHub repo
  2. Go to https://vercel.com/new
  3. Import the repository
  4. Set Root Directory to frontend
  5. Add environment variables in the Vercel dashboard
  6. Click Deploy

Testing the Flows

Flow 1: Mint PCT (Originator)

  1. Connect wallet to Arbitrum Sepolia
  2. Go to 01 / Mint tab
  3. Enter amount (e.g. 1000)
  4. Click Mint PCT
  5. Approve transaction in wallet
  6. Check terminal log for confirmation

The deployer wallet is the contract owner. Only the owner can mint. If you want another wallet to mint, call transferOwnership() on the PCT contract.

Flow 2: Confidential Transfer

  1. Go to 02 / Transfer tab
  2. Enter a recipient address
  3. Enter amount (e.g. 100)
  4. Click Send (Confidential)
  5. Approve transaction in wallet

What happens on-chain:

  • ConfidentialTransfer(from, to) event is emitted — NO amount
  • The Arbiscan explorer will show 0 value transfer
  • The actual amount is ABI-encoded (simulating FHE encryption)

Flow 3: Deposit to Pool (Lender)

  1. First, mint some PCT to your wallet (Flow 1)
  2. Go to 03 / Deposit tab
  3. Enter deposit amount (e.g. 500)
  4. Click Deposit (Private)
  5. Two transactions fire:
    • confidentialApprove — authorises pool to pull PCT
    • confidentialTransfer — sends PCT to pool
  6. Your position shows as "Active (amount hidden)"
  7. Pool lender count increments

Privacy check on Arbiscan:

  • The Deposited event shows only your address
  • No amount is ever stored or emitted

Flow 4: Audit (Owner Only)

Call auditBalance(address) directly on Arbiscan (connected as owner):

  1. Go to Arbiscan → contract → Write (as owner)
  2. Call auditBalance(yourAddress) — returns plaintext balance
  3. This demonstrates selective disclosure for compliance

Deployed Contract Addresses

Fill these in after deployment:

Contract Network Address
PrivCreditToken (PCT) Arbitrum Sepolia 0x_FILL_AFTER_DEPLOY
PrivCreditPool Arbitrum Sepolia 0x_FILL_AFTER_DEPLOY

Arbiscan: https://sepolia.arbiscan.io/address/0x_FILL_AFTER_DEPLOY


Project Structure

privcredit/
├── contracts/                  # Hardhat project
│   ├── contracts/
│   │   ├── PrivCreditToken.sol # ERC-7984 Confidential Token
│   │   └── PrivCreditPool.sol  # Private lending pool
│   ├── scripts/
│   │   └── deploy.ts           # Deployment script
│   ├── hardhat.config.ts
│   ├── package.json
│   ├── tsconfig.json
│   └── .env.example
│
└── frontend/                   # Next.js 15 app
    ├── app/
    │   ├── page.tsx            # Main interactive UI
    │   ├── layout.tsx          # Root layout
    │   ├── providers.tsx       # Wagmi + RainbowKit providers
    │   ├── wagmi.ts            # Chain config + contract ABIs
    │   └── globals.css         # Dark cipher aesthetic
    ├── next.config.js
    ├── tailwind.config.js
    ├── package.json
    └── .env.local.example

About

A decentralized platform where businesses (or originators) tokenize private credit (invoices, revenue-based loans, SME debt) as compliant ERC-3643 + ERC-7984 Confidential Tokens. Lenders provide liquidity privately, borrowers get funding, and positions/yields stay completely hidden from public view.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors