A comprehensive blockchain-based Point of Sale system for supermarkets, built on Base Layer 2 blockchain. The system enables secure cryptocurrency payments (ETH and USDC) through smart contracts, with a modern React frontend featuring WalletConnect integration for seamless wallet connectivity.
- Overview
- Architecture
- System Flow
- Contract Interaction
- Features
- Technology Stack
- Prerequisites
- Installation
- Usage
- Testing
- Deployment
- API Reference
- Contributing
- Security
- License
- Contact
Supermarket POS is a decentralized payment solution that revolutionizes retail transactions by leveraging blockchain technology. The system consists of:
- Smart Contracts: Secure payment vault on Base Sepolia testnet handling ETH and USDC deposits/withdrawals
- Frontend Application: Modern React-based interface with WalletConnect integration
- Protocol Fees: 0.5% automatic fee collection for ecosystem development
- Merchant Management: Authorized withdrawal system for registered merchants
| Component | Technology | Purpose |
|---|---|---|
SuperPOS.sol |
Solidity ^0.8.24 | Main payment contract |
wagmi.ts |
TypeScript | Blockchain connection configuration |
App.tsx |
React 19.2.3 | Main application interface |
ConnectKit |
WalletConnect | Wallet integration |
graph TB
subgraph "Frontend Layer"
A[React Application]
B[WalletConnect Integration]
C[ConnectKit UI]
end
subgraph "Smart Contract Layer"
D[SuperPOS Contract]
E[Payment Vault]
F[Merchant Registry]
end
subgraph "Blockchain Layer"
G[Base Sepolia]
H[ETH/USDC Tokens]
I[Event Logs]
end
A --> B
B --> C
C --> D
D --> E
D --> F
E --> G
F --> G
G --> H
G --> I
graph LR
subgraph "User Interface"
UI1[Payment Interface]
UI2[Merchant Dashboard]
UI3[Transaction History]
end
subgraph "Business Logic"
BL1[Wallet Connection]
BL2[Payment Processing]
BL3[Merchant Authorization]
end
subgraph "Data Layer"
DL1[Contract State]
DL2[Transaction Events]
DL3[Balance Tracking]
end
UI1 --> BL1
UI2 --> BL2
UI3 --> BL3
BL1 --> DL1
BL2 --> DL2
BL3 --> DL3
sequenceDiagram
participant Customer
participant Frontend
participant Wallet
participant Contract
participant Merchant
Customer->>Frontend: Select payment method (ETH/USDC)
Frontend->>Wallet: Request connection
Wallet->>Frontend: Connected wallet
Frontend->>Contract: Initiate deposit transaction
Contract->>Contract: Process payment + 0.5% fee
Contract->>Frontend: Transaction confirmed
Frontend->>Customer: Payment successful
Note over Merchant: Later withdrawal
Merchant->>Frontend: Request withdrawal
Frontend->>Contract: Verify merchant authorization
Contract->>Contract: Calculate fee deduction
Contract->>Merchant: Transfer funds
Contract->>Contract: Send fee to treasury
flowchart TD
A[Customer scans QR] --> B{Select Currency}
B -->|ETH| C[Connect Wallet]
B -->|USDC| C
C --> D[Approve Transaction]
D --> E[Execute Deposit]
E --> F[Contract Processes]
F --> G{Valid Payment?}
G -->|Yes| H[Update Balance]
G -->|No| I[Revert Transaction]
H --> J[Merchant Can Withdraw]
J --> K[Merchant Requests Withdrawal]
K --> L[Contract Verifies Merchant]
L --> M{Deduct 0.5% Fee}
M --> N[Transfer to Merchant]
M --> O[Send Fee to Treasury]
graph TD
subgraph "Frontend Calls"
A1[depositETH()]
A2[depositUSDC()]
A3[withdraw()]
A4[getBalance()]
end
subgraph "Contract Functions"
B1[Deposit Processing]
B2[Fee Calculation]
B3[Merchant Verification]
B4[Balance Updates]
end
subgraph "Events Emitted"
C1[Deposit Event]
C2[Withdrawal Event]
C3[MerchantAdded Event]
end
A1 --> B1
A2 --> B1
A3 --> B3
A4 --> B4
B1 --> C1
B2 --> C2
B3 --> C2
stateDiagram-v2
[*] --> Connected
Connected --> Depositing : depositETH/USDC
Depositing --> BalanceUpdated : Success
Depositing --> Error : Failed
BalanceUpdated --> Withdrawing : withdraw
Withdrawing --> FundsTransferred : Success
Withdrawing --> Error : Failed
Error --> Connected
FundsTransferred --> [*]
- Multi-Currency Payments: Support for ETH and USDC transactions
- Secure Vault: Smart contract-based payment storage
- Merchant Authorization: Controlled withdrawal system
- Protocol Fees: Automatic 0.5% fee collection
- Real-time Balances: On-chain balance tracking
- Wallet Integration: Seamless WalletConnect connectivity
- Responsive Design: Mobile-first React interface
- Transaction History: Complete payment tracking
- Error Handling: Comprehensive error management
- Gas Optimization: Efficient contract interactions
- Access Control: Owner and merchant role management
- Input Validation: Comprehensive parameter checking
- Emergency Functions: Owner-only emergency withdrawals
- Pause Mechanism: Circuit breaker functionality
- Event Logging: Transparent transaction records
- Solidity: ^0.8.24 - Smart contract development
- Foundry: Development framework and testing
- OpenZeppelin: Security libraries and standards
- Base Sepolia: Testnet deployment network
- React: 19.2.3 - UI framework
- TypeScript: 5.0+ - Type-safe development
- Vite: Build tool and dev server
- Tailwind CSS: Utility-first styling
- ConnectKit: WalletConnect UI components
- wagmi: React hooks for Ethereum
- Ethers.js: Ethereum interaction library
- WalletConnect: Cross-platform wallet connectivity
- Base: Layer 2 scaling solution
- ESLint: Code linting
- Prettier: Code formatting
- Husky: Git hooks
- Commitlint: Commit message standards
- Node.js: v18.0.0 or higher
- npm/pnpm/yarn: Latest stable version
- Git: v2.30.0 or higher
- Foundry: For smart contract development
- MetaMask: Or compatible Web3 wallet
- Base Network: Added to wallet (Mainnet/Sepolia)
- WalletConnect Project ID: From WalletConnect Cloud
- Infura/Alchemy: Optional for enhanced RPC
git clone https://github.com/your-username/supermarket-pos.git
cd supermarket-pos# Copy environment template
cp .env.example .env
# Add your WalletConnect Project ID
echo "VITE_WALLETCONNECT_PROJECT_ID=your_project_id_here" >> .envcd contract-solidity
# Install dependencies
forge install
# Run tests
forge test# Install dependencies
npm install
# Start development server
npm run dev- Connect Wallet: Use WalletConnect to connect your Web3 wallet
- Select Payment: Choose ETH or USDC payment method
- Scan QR: Scan the generated QR code at supermarket POS
- Confirm Transaction: Approve the payment in your wallet
- Receive Confirmation: Get instant transaction confirmation
- Register: Get authorized by contract owner
- Monitor Balances: View accumulated payments
- Withdraw Funds: Request withdrawals (0.5% protocol fee applied)
- Track Revenue: Monitor transaction history
# Start frontend development
npm run dev
# Build for production
npm run build
# Preview production build
npm run previewcd contract-solidity
# Run all tests
forge test
# Run with gas reporting
forge test --gas-report
# Run specific test file
forge test --match-path test/SuperPOS.t.sol
# Run with coverage
forge coverage# Run unit tests
npm test
# Run with coverage
npm test -- --coverage
# Run E2E tests (if configured)
npm run test:e2e# Test contract-frontend integration
npm run test:integrationcd contract-solidity
# Deploy using script
./deploy-superpos-testnet.sh
# Or manual deployment
forge script script/DeploySuperPOS.s.sol \
--rpc-url https://sepolia.base.org \
--private-key $PRIVATE_KEY \
--broadcast \
--verify# Deploy to mainnet
./deploy-superpos-mainnet.sh# Build application
npm run build
# Deploy to hosting service (Vercel, Netlify, etc.)
# Follow your hosting provider's instructionsdepositETH()- Deposit ETH to vaultdepositUSDC(uint256 amount)- Deposit USDC tokenswithdraw(string currency, address to, uint256 amount)- Withdraw funds (merchants only)addMerchant(address merchant)- Add authorized merchant (owner only)emergencyWithdraw(string currency, address to, uint256 amount)- Emergency withdrawal (owner only)
getBalance(string currency)- Get contract balance for currencyisMerchant(address account)- Check merchant authorizationowner()- Get contract ownerpaused()- Check if contract is paused
Deposit(address from, uint256 amount, string currency, uint256 timestamp)Withdrawal(address merchant, uint256 amountReceived, uint256 feeTaken, string currency, uint256 timestamp)MerchantAdded(address merchant, address owner)MerchantRemoved(address merchant, address owner)
App- Main application componentConnectKitButton- Wallet connection interfacePaymentInterface- Payment selection and processingMerchantDashboard- Merchant management interfaceTransactionHistory- Transaction display component
We welcome contributions from the community. Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes with proper tests
- Ensure all tests pass:
npm test && forge test - Commit with conventional format:
git commit -m "feat: add new feature" - Push to your branch:
git push origin feature/your-feature-name - Create a Pull Request
- Solidity: Follow OpenZeppelin guidelines
- TypeScript: Strict type checking enabled
- React: Functional components with hooks
- Styling: Tailwind CSS utility classes
- Testing: 100% test coverage for contracts
We use Conventional Commits:
feat:- New featuresfix:- Bug fixesdocs:- Documentation updatestest:- Testing related changesrefactor:- Code refactoring
- Audited Code: Contracts follow OpenZeppelin standards
- Access Control: Owner and merchant role separation
- Input Validation: Comprehensive parameter checking
- Emergency Functions: Owner-only emergency mechanisms
- Pause Functionality: Circuit breaker for critical situations
- Wallet Security: Secure wallet connection handling
- Input Sanitization: Client-side input validation
- HTTPS Only: Secure communication channels
- Dependency Updates: Regular security updates
Please report security vulnerabilities to: security@supermarket-pos.com
This project is licensed under the MIT License - see the LICENSE file for details.
Supermarket POS Team
- Website: https://supermarket-pos.com
- Documentation: https://docs.supermarket-pos.com
- GitHub: https://github.com/your-username/supermarket-pos
- Discord: Join our community
- Twitter: @SupermarketPOS
Built for the future of retail payments

