PRIV ProtocolPRIV Docs
Contracts

Smart Contracts

On-chain infrastructure for PRIV Protocol on Base.

Overview

PRIV Protocol is built on Base (Chain ID: 8453) using Solidity 0.8.24. The protocol consists of 8 smart contracts that 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

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. DataXchange]
    A --> F[6. AdNetwork]
    A --> G[7. DataContribution]
    A --> H[8. LabelingRewards]

    subgraph "Token Layer"
        A
    end

    subgraph "Governance Layer"
        B
        C
    end

    subgraph "Application Layer"
        D
        E
        F
        G
        H
    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. DataXchange - Deploy with PRIVToken and treasury addresses
  6. AdNetwork - Deploy with PRIVToken and oracle addresses
  7. DataContribution - Deploy with PRIVToken and oracle addresses
  8. LabelingRewards - Deploy with PRIVToken and oracle addresses

Deployments

Base Mainnet

ContractAddress
PRIVTokenComing Soon
PRIVStakingComing Soon
DataXchangeComing Soon
AdNetworkComing Soon
DataContributionComing Soon
LabelingRewardsComing Soon
PRIVGovernorComing Soon
PRIVTimelockComing Soon

Base Sepolia (Testnet)

ContractAddress
PRIVToken0x04eb3C2B5bC3A3590aCC57819cCA4D826EdC4Bd4
DataXchange0x832eA5F53D46A0f5F33Ac90F75eb7D4c043fc44c
AdNetwork0x97f41B81DF6Ae0676AD26446c99954d8A5B184e8
PRIVStakingComing Soon
DataContributionComing Soon
LabelingRewardsComing Soon
PRIVGovernorComing Soon
PRIVTimelockComing Soon

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/Deploy.s.sol --rpc-url base --broadcast

Contract Documentation

Core Token

  • PRIV Token - Native protocol token with governance voting

DeFi

  • Staking - Stake PRIV tokens to earn rewards

Marketplaces

  • DataXchange - Data marketplace with timelock protection
  • AdNetwork - Advertising network with multi-oracle consensus

Data Rewards

Governance

  • Governance - DAO governance with PRIVGovernor and PRIVTimelock