A complete Web3 solution for creating, issuing, redeeming, and managing digital vouchers on the blockchain
VoucherHub is a great decentralized platform that enables merchants to create, distribute, and manage digital vouchers and users to get and redeem them using blockchain technology. Built with modern Web3 technologies, it provides a secure, transparent, and efficient way to handle voucher transactions without intermediaries.
- πͺ Merchant Registration: Secure merchant onboarding with admin approval
- ποΈ Voucher Creation: Create digital vouchers with custom metadata and pricing
- π Secure Issuing: EIP712 signature-based voucher issuing system
- π° Marketplace: Browse vouchers and approach respective merchants for purchase
- π Redemption System: Easy voucher redemption with burn mechanism
- π¨βπΌ Admin Dashboard: Complete admin control over merchant approvals and voucher management
- π± Responsive UI: Modern interface built with React and Tailwind CSS
VoucherHub follows a modern three-tier architecture:
βββββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββββ
β Frontend β β Backend β β Smart Contracts β
β (React) βββββΊβ (Node.js) βββββΊβ (Solidity) β
β β β β β β
β β’ User Interface β β β’ API Server β β β’ VoucherERC1155 β
β β’ Web3 Integrationβ β β’ Database β β β’ MerchantRegistryβ
β β’ Wallet Connect β β β’ Authenticationβ β β’ OpenZeppelin β
βββββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββββ
- React 18.3.1 - Modern UI framework
- Vite - Fast build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- Ethers.js 5.8.0 - Ethereum interaction library
- React Router - Client-side routing
- Axios - HTTP client for API calls
- Node.js 20.19 - JavaScript runtime
- Express.js - Web application framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - JSON Web Token authentication
- Helmet - Security middleware
- Solidity 0.8.20 - Smart contract language
- Foundry - Development framework
- OpenZeppelin - Security-audited contract libraries
- ERC1155 - Multi-token standard
- EIP712 - Typed structured data signing
- ESLint - Code linting
- Nodemon - Development server
- Pinata (IPFS) - Decentralized storage & pinning service
- Foundry - Smart contract development framework
VoucherHub/
β
βββ π frontend/ # React frontend application
β βββ π src/
β β β
β β βββ π Components/ # Reusable UI components
β β β βββ π admin/ # Admin-specific components
β β β βββ π common/ # Shared components
β β β βββ π connect/ # Wallet connection
β β β βββ π merchant/ # Merchant dashboard
β β β βββ π user/ # User interface
β β β
β β βββ π Context/ # React context providers
β β β βββ RoleContext.jsx # User role management
β β β βββ WalletContext.jsx # Web3 wallet integration
β β β
β β βββ π Pages/ # Application pages
β β β βββ AdminPage.jsx # Admin dashboard
β β β βββ ConnectPage.jsx # Wallet connection page
β β β βββ Marketplace.jsx # Voucher marketplace
β β β βββ MerchantPage.jsx # Merchant dashboard
β β β βββ UserPage.jsx # User dashboard
β β β
β β βββ π utils/ # Utility functions & services
β β β βββ eip712.js # EIP712 signature utilities
β β β βββ fetchVouchers.js # Voucher data fetching
β β β βββ ipfs.js # IPFS integration
β β β βββ roleDetection.js # User role detection
β β β βββ utilsMerchantRequests.js # Merchant request utilities
β β β
β β βββ App.jsx # Main application component
β β βββ main.jsx # Application entry point
β β βββ index.css # Global styles
β β
β βββ package.json
β βββ vite.config.js
β
βββ π backend/ # Express.js backend server
β βββ π src/
β β β
β β βββ π config/ # Configuration files
β β β βββ db.js # Database connection setup
β β β
β β βββ π controllers/ # Request handlers
β β β βββ merchantRequestController.js # Merchant request logic
β β β βββ voucherController.js # Voucher CRUD operations
β β β
β β βββ π middleware/ # Authentication & validation
β β β βββ authMiddleware.js # JWT authentication
β β β βββ validateVoucher.js # Voucher validation
β β β
β β βββ π models/ # Database models
β β β βββ MerchantRequest.js # Merchant request schema
β β β βββ Voucher.js # Voucher schema
β β β
β β βββ π routes/ # API routes
β β βββ merchantRequestRoutes.js # Merchant request endpoints
β β βββ voucherRoutes.js # Voucher endpoints
β β
β βββ package.json
β βββ server.js # Express server entry point
β
βββ π contracts/ # Smart contracts
β βββ π src/ # Solidity contracts
β β βββ VoucherERC1155.sol # Main voucher contract (ERC1155)
β β βββ MerchantRegistry.sol # Merchant registration & management
β β
β βββ π script/ # Deployment scripts
β βββ π test/ # Contract tests
β βββ foundry.toml # Foundry configuration
β
βββ π spec/ # Project specifications
βββ README.md # Project documentation
- Node.js (v20.19 or higher)
- npm or yarn
- Git
- MetaMask or compatible Web3 wallet
- MongoDB (local or cloud instance)
- Pinata Account (for IPFS storage)
-
Clone the repository
git clone https://github.com/veyrix-Tr/VoucherHub.git cd VoucherHub -
Install dependencies for all components
# Install frontend dependencies cd frontend npm install # Install backend dependencies cd ../backend npm install # Install contract dependencies cd ../contracts forge install forge build
-
Environment Setup
Frontend (.env)
VITE_BACKEND_URL=http://localhost:5000 VITE_CHAIN_ID=11155111 VITE_PINATA_JWT=your_pinata_jwt_token VITE_PINATA_GATEWAY=https://gateway.pinata.cloud
Backend (.env)
PORT=5000 MONGODB_URI=mongodb://localhost:27017/voucherhub JWT_SECRET=your_jwt_secret_key # Note: JWT authentication currently disabled for development RPC_URL=your_rpc_url CHAIN_ID=11155111
-
Start the servers
Terminal 1 - Backend
cd backend npm run devTerminal 2 - Frontend
cd frontend npm run dev
The main contract that handles voucher creation, minting, and redemption.
Key Functions:
mintFromVoucher()- Mint vouchers using EIP712 signaturesburnForRedeem()- Redeem and burn voucherssetVoucherApproval()- Admin approval for voucher creationissueVoucherToUser()- Direct voucher issuance by merchants
Manages merchant registration and verification.
Key Functions:
registerMerchant()- Register new merchants (admin only)updateMerchantStatus()- Activate/deactivate merchantsisMerchant()- Check if address is an active merchant
- Merchant Registration - Merchants submit registration requests through the platform
- Admin Approval - Admins review and approve/reject merchant applications
- Voucher Creation - Approved merchants create vouchers with EIP712 signatures
- Voucher Approval - Admins approve vouchers before users can mint them
- Voucher Distribution - Users mint approved vouchers; merchants may also issue them directly to users.
- Voucher Usage - Users approach merchants to use their vouchers
- Voucher Redemption - Users redeem vouchers, which burns the tokens permanently
- Browse marketplace
- Purchase vouchers
- Redeem vouchers
- View transaction history
- Create voucher listings
- Manage voucher inventory
- Track sales and redemptions
- Update voucher metadata
- Approve/reject merchant applications
- Approve/reject voucher listings
- Monitor platform activity
- Manage system settings
GET /api/vouchers # Get all vouchers
POST /api/vouchers # Create new voucher
GET /api/vouchers/:id # Get voucher by ID
PUT /api/vouchers/:id/approve # Approve voucher (admin only)
PUT /api/vouchers/:id/reject # Reject voucher (admin only)
PUT /api/vouchers/:id/redeem # Redeem voucher
PUT /api/vouchers/:id/minted # Update minted count
POST /api/merchant-requests # Submit merchant application
GET /api/merchant-requests/me # Get my merchant request
GET /api/merchant-requests # Get all requests (admin only)
PUT /api/merchant-requests/:id/approve # Approve merchant (admin only)
PUT /api/merchant-requests/:id/reject # Reject merchant (admin only)
cd contracts
forge test -vvcd backend
npm startcd frontend
npm run build
npm run previewThis project is licensed under the MIT License.
If you encounter any issues or have questions:
- π§ Email: chiraggoyal3637@gmail.com
- π Issues: GitHub Issues
- π¦ Twitter: @veyrix_Tr
- OpenZeppelin for secure smart contract libraries
- The Ethereum community for Web3 standards
- React and Node.js communities for excellent frameworks
Made with β€οΈ by the veyrix-Tr [Chirag Goyal]