Skip to content

Saber1Y/Payyr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Payyr - USDC Automated Payroll System on Arc Network

A modern, multi-tenant automated payroll system built on Arc Network, enabling seamless USDC payments to employees with a beautiful fintech-style interface. Self-service employer registration allows unlimited companies to share the same smart contracts.

🌟 Features

  • Multi-Tenant Architecture: Unlimited companies share the same smart contracts with isolated operations
  • Self-Service Registration: Any wallet can register as an employer - no admin needed
  • Modern UI: Clean, fintech-inspired interface built with Next.js 14 and TailwindCSS
  • Employee Management: Add, edit, and manage employee profiles with wallet addresses
  • Automated Payroll: Schedule and execute automated USDC payments
  • Dashboard Analytics: Real-time overview of payroll metrics and balances
  • Smart Contracts: Solidity contracts built with Foundry for secure payments
  • Arc Network Integration: Leveraging Arc Network for fast, low-cost transactions
  • Role-Based Access Control: HR_ROLE for employers, ADMIN_ROLE for platform owner

πŸ”„ How It Works

For Employers (Self-Service Flow)

1. Connect Wallet
   β†’ Your wallet address is your identity

2. Register as Employer
   β†’ Click "Register as Employer" button
   β†’ Calls registerAsEmployer() contract function
   β†’ Automatically granted HR_ROLE
   β†’ Cost: ~$0.08 in gas

3. Add Your Employees
   β†’ Go to Employees page
   β†’ Click "Add Employee"
   β†’ Enter: Name, Wallet Address, Salary, Role
   β†’ Employee linked to your employer address
   β†’ Only YOU can manage your employees
   β†’ Cost: ~$0.19 per employee

4. Deposit USDC for Payroll
   β†’ Go to Payroll page
   β†’ Approve USDC spending (one-time)
   β†’ Deposit desired amount
   β†’ Funds tracked in your employer balance
   β†’ Cost: ~$0.17 (approve + deposit)

5. Execute Payroll
   β†’ Click "Pay All Employees"
   β†’ Contract pays only YOUR employees
   β†’ Deducts from your employer balance
   β†’ Instant USDC transfers to employee wallets
   β†’ Cost: ~$0.24 per employee

Multi-Tenant Isolation

All employers share the same contracts but operate independently:

// Each employer has their own balance
employerBalances[companyA] = 10_000 USDC
employerBalances[companyB] = 5_000 USDC

// Each employer manages only their employees
getEmployerEmployees(companyA) β†’ [emp1, emp2, emp3]
getEmployerEmployees(companyB) β†’ [emp4, emp5]

// Payroll is isolated
companyA.executePayroll() β†’ pays emp1, emp2, emp3
companyB.executePayroll() β†’ pays emp4, emp5

πŸ—οΈ Architecture

Smart Contracts

EmployeeRegistry (0x20B3dB45a351E92673112064A3F01951115eD6B7)

  • Manages employee records
  • Links employees to employers
  • Handles employer registration
  • Tracks employer-employee relationships

PayrollManager (0x1739715A3452BF1e336305cf8f9542d177cEa03A)

  • Manages USDC deposits
  • Executes payroll per employer
  • Tracks employer balances
  • Handles payroll history

Frontend Application

frontend/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ dashboard/    # Platform overview & statistics
β”‚   β”œβ”€β”€ employees/    # Employee management with employer registration
β”‚   β”œβ”€β”€ payroll/      # USDC deposits & payroll execution
β”‚   └── settings/    # User preferences
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ui/          # shadcn/ui components
β”‚   └── providers/  # Wallet & context providers
└── lib/
    └── abi/         # Smart contract ABIs

πŸ’° Gas Costs

Deployment (Platform Owner - One-Time)

Contract Est. Gas Cost (USDC)
EmployeeRegistry ~1.5M $2.40
PayrollManager ~2.6M $4.16
Total Deployment ~4.1M $6.56

User Operations

Operation Est. Gas Cost (USDC)
Register as Employer 50,000 $0.08
Add Employee 120,000 $0.19
Update Employee 90,000 $0.14
Deactivate Employee 80,000 $0.13
Approve USDC (once) 40,000 $0.06
Deposit Payroll 70,000 $0.11
Execute Payroll (per employee) 150,000 $0.24

Assumptions: 160 gwei gas price, $0.0016 per gas unit on Arc Network

Cost Example: Company with 5 Employees

  • Register as employer: $0.08
  • Add 5 employees: $0.95
  • Approve USDC (one-time): $0.06
  • Deposit $10,000: $0.11
  • Execute payroll (5 employees): $1.20
  • Total: $2.40 per payroll run

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ installed
  • Foundry installed (for smart contract development)
  • Wallet with Arc Network USDC

Backend (Smart Contracts)

cd Backend
forge install
forge build
forge test

# Deploy to Arc Network
forge script script/DeployDirect.s.sol --rpc-url $RPC_URL --broadcast

Frontend (Web Application)

cd frontend
npm install
npm run dev

Open http://localhost:3000 to view the application.

Quick Start for New Users

  1. Connect your wallet - Click the connect button in the top right
  2. Register as employer - Go to Employees page and click "Register as Employer"
  3. Add your team - Add employees with their wallet addresses and salaries
  4. Fund your payroll - Go to Payroll page and deposit USDC
  5. Pay your team - Click "Pay All Employees" to execute payroll

πŸ› οΈ Tech Stack

Frontend

  • Next.js 14 - React framework with app router
  • TypeScript - Type-safe development
  • TailwindCSS - Utility-first styling
  • shadcn/ui - Modern component library
  • Privy - Embedded wallet authentication
  • Wagmi - React hooks for Ethereum
  • Lucide React - Beautiful icons

Backend

  • Foundry - Smart contract development framework
  • Solidity - Smart contract programming language
  • OpenZeppelin - Security libraries (AccessControl, ReentrancyGuard, Pausable)
  • Arc Network - Layer 2 blockchain for fast, cheap transactions

πŸ“Š Pages & Features

Dashboard

  • Platform-wide statistics
  • Recent payroll runs
  • Total contract balance (admin view)

Employees

  • Employer Registration - Self-service onboarding
  • Employee List - View your team members
  • Add Employee - Add new team members
  • Edit Employee - Update employee details
  • Activate/Deactivate - Manage employee status

Payroll

  • Deposit USDC - Fund your payroll account
  • View Balance - Check your available funds
  • Execute Payroll - Pay all active employees
  • Payroll History - View past runs

Settings

  • Company information
  • Payment preferences
  • Wallet management

πŸ” Security Features

  • Wallet-based authentication - Secure login via Privy
  • Role-based access control - Employers only manage their employees
  • Isolated employer balances - Funds separated per employer
  • ReentrancyGuard - Prevent reentrancy attacks
  • Pausable - Emergency pause functionality
  • Audit-ready code - Clean, well-documented contracts

🎯 Why This Is Great for Arc Rewards

  1. Multi-Tenant Design - Scalable to unlimited companies
  2. Self-Service - No manual onboarding required
  3. Gas Efficient - Shared contracts = lower costs for users
  4. Real Utility - Actual payroll management use case
  5. Production Ready - Complete frontend + backend
  6. Low Barrier - $0.08 to become an employer

πŸ“„ License

This project is open source and available under the MIT License.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“ž Support

For support and questions, please open an issue in this repository.

About

A modern, multi-tenant automated payroll system built on Arc Network, enabling seamless USDC payments to employees with a beautiful fintech-style interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors