Skip to content

Web3 payment platform connecting ENS identities with Mexican fiscal invoicing (CFDI) - ETH Mexico 2025 Hackathon

License

Notifications You must be signed in to change notification settings

Arturou/paychain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PayChain πŸ’°

πŸ† ETH Mexico 2025 Hackathon Project

Web3 payment platform connecting ENS identities with Mexican fiscal invoicing (CFDI)

ETH Mexico 2025 License: MIT Solidity Next.js

Contract deployed on Scroll Sepolia: https://sepolia.scrollscan.com/address/0x60814008211E98dbc88E08266FB220F41F1b850E#code

PayChain enables businesses and freelancers in Mexico to receive cryptocurrency payments using memorable ENS names while automatically generating legally valid tax receipts (CFDI 4.0).

🎯 Key Features

  • 🌐 ENS Integration: Accept payments at yourcompany.eth instead of 0x742d35...
  • ⚑ Scroll L2: Fast (<5s) and cheap (<$0.50) transactions
  • πŸ“„ Auto-Invoicing: CFDI 4.0 compliant invoices via Facturapi
  • πŸ“Š Provider Dashboard: View payments and download invoices
  • πŸ“§ Email Notifications: Automatic receipt delivery
  • πŸ’± Multi-Currency: Support for ETH, USDC, USDT with automatic MXN conversion

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Next.js UI    β”‚  Frontend (Vercel)
β”‚   + wagmi/viem  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTPS
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Express API    │◄─────►│ PostgreSQL   β”‚
β”‚  + TypeScript   β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                β”‚    Redis     β”‚
         β”‚                β”‚  (Job Queue) β”‚
         β”‚                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”œβ”€β”€β–Ί Scroll L2 (Events)
         β”œβ”€β”€β–Ί Facturapi (Invoices)
         β”œβ”€β”€β–Ί CoinGecko (Exchange Rates)
         └──► Resend (Emails)

πŸš€ Quick Start

Prerequisites

  • Node.js 20+
  • PostgreSQL 15+
  • Redis 7+
  • Foundry (for smart contracts)
  • MetaMask or compatible Web3 wallet

Installation

  1. Clone the repository
git clone https://github.com/yourusername/paychain.git
cd paychain
  1. Install dependencies
# Smart contracts
cd contracts && forge install && cd ..

# Backend
cd backend && npm install && cd ..

# Frontend
cd frontend && npm install && cd ..
  1. Set up environment variables
# Copy example files
cp .env.example .env
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env.local

# Edit each .env file with your actual API keys and configuration
  1. Set up the database
# Create database
createdb paychain

# Run migrations
psql paychain < backend/database/schema.sql

Development

Run these commands in separate terminals:

# Terminal 1: Start Redis
redis-server

# Terminal 2: Start Backend API
cd backend && npm run dev

# Terminal 3: Start Background Worker
cd backend && npm run worker

# Terminal 4: Start Frontend
cd frontend && npm run dev

Visit http://localhost:3000 to see the application.

πŸ“š Project Structure

paychain/
β”œβ”€β”€ contracts/              # Solidity smart contracts
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── PayChain.sol   # Main payment contract
β”‚   β”œβ”€β”€ test/              # Contract tests
β”‚   └── script/            # Deployment scripts
β”‚
β”œβ”€β”€ backend/               # Express.js API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/       # API endpoints
β”‚   β”‚   β”œβ”€β”€ services/     # Business logic
β”‚   β”‚   β”œβ”€β”€ repositories/ # Database access
β”‚   β”‚   └── workers/      # Background jobs
β”‚   └── database/
β”‚       └── schema.sql    # Database schema
β”‚
β”œβ”€β”€ frontend/             # Next.js application
β”‚   β”œβ”€β”€ app/             # App router pages
β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”œβ”€β”€ lib/            # Utilities
β”‚   └── hooks/          # Custom React hooks
β”‚
└── docs/               # Additional documentation

πŸ§ͺ Testing

Smart Contracts

cd contracts
forge test -vv

Backend

cd backend
npm test

Frontend

cd frontend
npm test

🚒 Deployment

1. Deploy Smart Contract

cd contracts

# Deploy to Scroll Sepolia
forge script script/Deploy.s.sol \
  --rpc-url $SCROLL_RPC_URL \
  --broadcast \
  --verify

# Update CONTRACT_ADDRESS in .env files

2. Deploy Backend (Railway)

cd backend
railway login
railway init
railway up

3. Deploy Frontend (Vercel)

cd frontend
vercel --prod

πŸ”‘ Environment Variables

Required API Keys

  1. Facturapi (Mexican invoice generation)

  2. Resend (Email service)

  3. WalletConnect (Optional, for wallet connections)

  4. CoinGecko (Optional, for exchange rates)

See .env.example files for complete configuration details.

πŸ› οΈ Tech Stack

Layer Technology
Frontend Next.js 14, TypeScript, Tailwind CSS, shadcn/ui
Smart Contracts Solidity 0.8.20, Foundry, OpenZeppelin
Backend Node.js, Express, TypeScript
Database PostgreSQL, Kysely ORM
Blockchain Scroll Sepolia L2, ENS
Web3 wagmi, viem, ethers.js
Invoicing Facturapi API (CFDI 4.0)
Email Resend
Job Queue BullMQ + Redis

πŸ“– Documentation

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ”’ Security

  • Never commit .env files
  • Keep private keys secure
  • Use environment variables for all sensitive data
  • Report security vulnerabilities to security@paychain.app

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Team

Built with ❀️ by the PayChain Team for ETH Mexico 2025

πŸ™ Acknowledgments

  • ENS - Ethereum Name Service
  • Scroll - Layer 2 scaling solution
  • Facturapi - Mexican invoice generation
  • OpenZeppelin - Smart contract libraries

πŸ“ž Support


Made with ❀️ using ENS, Scroll, and Facturapi

About

Web3 payment platform connecting ENS identities with Mexican fiscal invoicing (CFDI) - ETH Mexico 2025 Hackathon

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published