PRIV ProtocolPRIV Docs
Contracts

Smart Contracts

On-chain infrastructure for PRIV Protocol on Base.

Overview

PRIV Protocol is implemented on Base Sepolia testnet using Solidity 0.8.24. Its smart contracts work together to enable privacy-preserving data exchange, advertising, staking, and governance.

ContractPurpose
PRIVTokenERC-20 token with ERC20Votes for governance
PRIVStakingStake PRIV tokens to earn rewards
DataXchangeMarketplace for privacy-preserving data exchange
AdNetworkDecentralized advertising with multi-oracle consensus
DataContributionRewards for data contributions (photos, videos, voice)
LabelingRewardsAI training labeling tasks with staking
PRIVGovernorDAO governance with proposal management
PRIVTimelockTimelock controller for governance execution
FeeManagerV2Central fee distribution (40% burn / 35% stakers / 25% treasury)
DataWalletMarketplaceBulk purchase marketplace for data wallet media
TokenDistributionV2Multi-tier token vesting and distribution (Founder, Treasury, Ecosystem)
MintingControllerPhase-based minting caps (10M/5M/2M)
FounderPerformanceBondTVL milestone-based token releases
PrivPresale10-stage presale with ETH/USDC/Card, Chainlink oracle, vesting
PriceOracleChainlink price feeds with staleness checks and manual override
PricingEnginePRIV/USD conversions and USDC integration
TreasuryProtocol treasury with multi-sig threshold management
TreasuryManagerAutomated treasury operations
BountyEscrowData bounty escrow with 3 payment tiers and auto-payout
ApproverRegistryGame-theory QA with stake-to-approve, consensus voting, slashing
PRIVStakingV2ve-PRIV staking with 5 lock tiers (Flex/Bronze/Silver/Gold/Diamond), weighted rewards, auto-compound

Network Information

PropertyValue
NetworkBase
Chain ID8453
Solidity Version0.8.24
Block Time~2 seconds

Deployment Order

The contracts must be deployed in a specific order due to dependencies:

graph TD
    A[1. PRIVToken] --> B[2. PRIVTimelock]
    A --> C[3. PRIVGovernor]
    B --> C
    A --> D[4. PRIVStaking]
    A --> E[5. FeeManager]
    E --> F[6. DataXchange]
    E --> G[7. AdNetwork]
    A --> H[8. DataContribution]
    A --> I[9. LabelingRewards]
    E --> J[10. DataWalletMarketplace]
    A --> K[11. TokenDistributionV2]
    A --> M[12. MintingController]
    A --> N[13. FounderPerformanceBond]

    subgraph "Token Layer"
        A
    end

    subgraph "Governance Layer"
        B
        C
    end

    subgraph "Fee Infrastructure"
        E
    end

    subgraph "Application Layer"
        D
        F
        G
        H
        I
        J
    end

    subgraph "Distribution Layer"
        K
        M
        N
    end

Deployment Steps:

  1. PRIVToken - Deploy first as the base token for the ecosystem
  2. PRIVTimelock - Deploy with initial delay (2 days recommended)
  3. PRIVGovernor - Deploy with PRIVToken and PRIVTimelock addresses
  4. PRIVStaking - Deploy with PRIVToken address
  5. FeeManagerV2 - Deploy with PRIVToken, staking, and treasury addresses
  6. DataXchange - Deploy with PRIVToken and FeeManagerV2 addresses
  7. AdNetwork - Deploy with PRIVToken, FeeManager, and oracle addresses
  8. DataContribution - Deploy with PRIVToken and oracle addresses
  9. LabelingRewards - Deploy with PRIVToken and oracle addresses
  10. DataWalletMarketplace - Deploy with PRIVToken and FeeManager addresses
  11. TokenDistributionV2 - Deploy with PRIVToken and beneficiary addresses
  12. MintingController - Deploy with PRIVToken address; configure phase caps (10M/5M/2M)
  13. FounderPerformanceBond - Deploy with PRIVToken and TVL oracle addresses; configure milestone amounts ($1M/$5M/$10M/$25M)
  14. PriceOracle - Deploy with Chainlink feed addresses
  15. PricingEngine - Deploy with PRIVToken, PriceOracle, and USDC addresses
  16. Treasury - Deploy with multi-sig configuration
  17. TreasuryManager - Deploy with Treasury and PRIVToken addresses
  18. BountyEscrow - Deploy with PRIVToken, FeeManagerV2, and oracle addresses
  19. ApproverRegistry - Deploy with PRIVToken address; register as BountyEscrow oracle
  20. PRIVStakingV2 - Deploy with PRIVToken address and reward rate; fund rewards pool

Deployments

Base Mainnet

ContractAddress
PRIVTokenComing Soon
PRIVStakingComing Soon
FeeManagerComing Soon
DataXchangeComing Soon
AdNetworkComing Soon
DataContributionComing Soon
LabelingRewardsComing Soon
DataWalletMarketplaceComing Soon
TokenDistributionV2Coming Soon
MintingControllerComing Soon
FounderPerformanceBondComing Soon
PRIVGovernorComing Soon
PRIVTimelockComing Soon

Base Sepolia (Testnet)

Testnet contracts deployed and verified; no mainnet deployment or external security audit yet. See packages/contracts/deployments/base-sepolia.json for full address list.


Architecture

                         +-----------------+
                         |   PRIVToken     |
                         |  (ERC20Votes)   |
                         +--------+--------+
                                  |
        +------------+------------+------------+------------+
        |            |            |            |            |
        v            v            v            v            v
+-------------+ +----------+ +----------+ +----------+ +----------+
| PRIVStaking | | DataX-   | | AdNetwork| | Data-    | | Labeling |
|             | | change   | |          | | Contrib  | | Rewards  |
+-------------+ +----------+ +----------+ +----------+ +----------+
                                  ^
                                  |
                         +--------+--------+
                         |                 |
                    +----+----+      +-----+-----+
                    | PRIV    |      | PRIV      |
                    | Governor|----->| Timelock  |
                    +---------+      +-----------+

Token Flow:

  • All contracts use PRIV tokens for payments and rewards
  • The token contract manages supply and minting
  • Governance controls protocol parameters through timelock

Security Features

All contracts implement robust security patterns:

FeatureDescription
ReentrancyGuardProtection against reentrancy attacks
SafeERC20Safe token transfer handling
OwnableAccess control for admin functions
PausableEmergency pause functionality
Multi-Oracle ConsensusM-of-N confirmation for critical operations
Timelock ProtectionDelayed execution for governance and price updates
Custom ErrorsGas-efficient error handling

Development

Local Setup

cd packages/contracts
forge install
forge build

Running Tests

# Run all tests
forge test

# Run with verbosity
forge test -vvv

# Gas report
forge test --gas-report

Deploy

# Deploy to Base Sepolia
forge script script/Deploy.s.sol --rpc-url base-sepolia --broadcast

# Deploy to Base Mainnet
forge script script/DeployMainnet.s.sol:DeployMainnet --rpc-url base --broadcast

Contract Documentation

Core Token

  • PRIV Token - Native protocol token with governance voting

DeFi

  • StakingV2 - ve-PRIV staking with 5 lock tiers and weighted rewards

Fee Infrastructure

  • FeeManagerV2 - Central hub for processing and distributing protocol fees (40% burn / 35% stakers / 25% treasury)

Marketplaces

  • DataXchange - Data marketplace with timelock protection
  • AdNetwork - Advertising network with multi-oracle consensus
  • DataWalletMarketplace - Bulk purchase marketplace for data wallet media (3% fee)

Data Rewards

Token Distribution

  • TokenDistributionV2 - Multi-tier vesting for Founder (3M TGE / 27M vested), Treasury, and Ecosystem allocations
  • FounderVesting has been retired and removed from the codebase (it was never deployed). The founder allocation is governed solely by TokenDistributionV2.

Data Bounty Board

  • BountyEscrow - Data bounty escrow with 3 payment tiers (Standard, DirectPRIV, StakedPRIV), auto-payout, FeeManagerV2 integration
  • ApproverRegistry - Game-theory QA with 500 PRIV stake, 3-vote quorum, 66.67% consensus, slashing

Governance

  • Governance - DAO governance with PRIVGovernor and PRIVTimelock