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.
| Contract | Purpose |
|---|---|
| PRIVToken | ERC-20 token with ERC20Votes for governance |
| PRIVStaking | Stake PRIV tokens to earn rewards |
| DataXchange | Marketplace for privacy-preserving data exchange |
| AdNetwork | Decentralized advertising with multi-oracle consensus |
| DataContribution | Rewards for data contributions (photos, videos, voice) |
| LabelingRewards | AI training labeling tasks with staking |
| PRIVGovernor | DAO governance with proposal management |
| PRIVTimelock | Timelock controller for governance execution |
Network Information
| Property | Value |
|---|---|
| Network | Base |
| Chain ID | 8453 |
| Solidity Version | 0.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
endDeployment Steps:
- PRIVToken - Deploy first as the base token for the ecosystem
- PRIVTimelock - Deploy with initial delay (2 days recommended)
- PRIVGovernor - Deploy with PRIVToken and PRIVTimelock addresses
- PRIVStaking - Deploy with PRIVToken address
- DataXchange - Deploy with PRIVToken and treasury addresses
- AdNetwork - Deploy with PRIVToken and oracle addresses
- DataContribution - Deploy with PRIVToken and oracle addresses
- LabelingRewards - Deploy with PRIVToken and oracle addresses
Deployments
Base Mainnet
| Contract | Address |
|---|---|
| PRIVToken | Coming Soon |
| PRIVStaking | Coming Soon |
| DataXchange | Coming Soon |
| AdNetwork | Coming Soon |
| DataContribution | Coming Soon |
| LabelingRewards | Coming Soon |
| PRIVGovernor | Coming Soon |
| PRIVTimelock | Coming Soon |
Base Sepolia (Testnet)
| Contract | Address |
|---|---|
| PRIVToken | 0x04eb3C2B5bC3A3590aCC57819cCA4D826EdC4Bd4 |
| DataXchange | 0x832eA5F53D46A0f5F33Ac90F75eb7D4c043fc44c |
| AdNetwork | 0x97f41B81DF6Ae0676AD26446c99954d8A5B184e8 |
| PRIVStaking | Coming Soon |
| DataContribution | Coming Soon |
| LabelingRewards | Coming Soon |
| PRIVGovernor | Coming Soon |
| PRIVTimelock | Coming 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:
| Feature | Description |
|---|---|
| ReentrancyGuard | Protection against reentrancy attacks |
| SafeERC20 | Safe token transfer handling |
| Ownable | Access control for admin functions |
| Pausable | Emergency pause functionality |
| Multi-Oracle Consensus | M-of-N confirmation for critical operations |
| Timelock Protection | Delayed execution for governance and price updates |
| Custom Errors | Gas-efficient error handling |
Development
Local Setup
cd packages/contracts
forge install
forge buildRunning Tests
# Run all tests
forge test
# Run with verbosity
forge test -vvv
# Gas report
forge test --gas-reportDeploy
# 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 --broadcastContract 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
- Data Contribution - Rewards for data uploads
- Labeling Rewards - AI training task marketplace
Governance
- Governance - DAO governance with PRIVGovernor and PRIVTimelock