AnyPay
NFC crypto payments: Turn smartphones into banking payment terminals.
Problem Statement
AnyPay is a React Native mobile app that enables instant cryptocurrency payments via NFC. Users tap phones to exchange payment details and complete transactions. Core Technology: Built with React Native and Expo for iOS and Android NFC communication: uses react-native-nfc-manager for reading and react-native-hce (Android Host Card Emulation) for sharing payment data Dark fintech UI with gradient animations and glassmorphism Blockchain Infrastructure: Cross-chain payments via Layer Zero Omnichain Protocol Automatic asset swapping via Uniswap when sender and recipient prefer different assets Supports Ethereum, Polygon, Arbitrum, and Optimism testnets Supports multiple tokens: USDC, USDT, ETH, wBTC User Experience: Send: choose asset/chain, tap recipient’s device, transaction executes automatically Receive: set amount and preferred asset/chain, wait for NFC tap, receive in preferred format Configuration: customize default send/receive chains, assets, and payment preferences Technical Flow: NFC exchange of payment details (address, amount, desired asset/chain) Source chain: sender’s asset locked in bridge contract Layer Zero: secure cross-chain message delivery Asset conversion: Uniswap swaps if needed Target chain: recipient receives preferred asset on preferred chain Key Features: Instant NFC-based payment initiation Cross-chain compatibility (send on one chain, receive on another) Automatic asset conversion (send ETH, receive USDC) Trustless execution via smart contracts Mobile-first design with smooth animations The project includes smart contracts for bridging, swapping, and cross-chain messaging, deployed on testnets for the EthGlobal Buenos Aires Hackathon. It demonstrates how NFC can simplify crypto payments while maintaining the flexibility of cross-chain and cross-asset transactions.
Solution
How It's Made - Technical DescriptionArchitecture OverviewThis project implements a cross-chain token bridging system that automatically bridges tokens after swaps, usingLayerZero V2for omnichain messaging andUniswap v4 hooksfor swap integration.Core TechnologiesLayerZero V2 OApp InfrastructureOApp Contracts: Built customSourceBridgeandTargetBridgecontracts inheriting from LayerZero'sOAppandOAppOptionsType3Cross-Chain Messaging: Uses LayerZero's messaging protocol to send lock/unlock instructions between Arbitrum Sepolia and Optimism SepoliaOptionsBuilder: Configured executor options with gas limits (200,000) for reliable message executionEndpoint IDs: Arbitrum Sepolia (40231) and Optimism Sepolia (40232)Smart Contract StackSolidity 0.8.24: All contracts written in modern Solidity with safety featuresOpenZeppelin Contracts v5: UsedSafeERC20for secure token transfers,Ownablefor access controlHardhat: Development environment with custom network configurations for testnetsUniswap v4 IntegrationBaseHook: Extended Uniswap'sBaseHookcontract to createBridgeHookHook Permissions: Configured withafterSwappermission flag (bit 7) for post-swap executionCREATE2 Deployment: Implemented deterministic deployment using CREATE2 to meet Uniswap v4's hook address requirementsBridgeHelper: Helper contract that interfaces between the hook and LayerZero bridgeTechnical Implementation DetailsBridge ArchitectureSourceBridge (Arbitrum Sepolia):Locks tokens when users bridgeSends cross-chain messages via LayerZero with recipient address and amountUsesquoteLockAndBridgeto calculate native fees before executionTargetBridge (Optimism Sepolia):Receives messages from source chainMints bridged tokens to recipientsHandles burn operations when users bridge backSwap-to-Bridge FlowUser performs a swap on Uniswap v4 poolBridgeHook'safterSwapcallback is triggered automaticallyBridgeHelper receives swap output and callslockAndBridgewith native ETH for feesSourceBridge locks tokens and sends LayerZero cross-chain messageTargetBridge receives message and mints bridged tokens on destination chainNFC Crypto Payment IntegrationContactless Payment Interface: NFC-enabled devices (smartphones, payment terminals) can trigger the swap and bridge flow with a single tapDirect Smart Contract Connection: NFC tap events connect directly to smart contracts, bypassing traditional payment processorsAutomated Transaction Execution: Upon NFC tap, the system automatically:Initiates the swap on Uniswap v4 poolTriggers the bridge hook to lock tokensSends cross-chain message via LayerZeroCompletes the entire payment flow in a single transactionSeamless User Experience: Users can make cross-chain crypto payments without manual transaction signing or wallet interactionsPayment Terminal Integration: NFC payment terminals can be configured to accept crypto payments that automatically bridge to recipient's preferred chainMulti-Chain Payment Support: Recipients can receive payments on their preferred chain, regardless of which chain the payment was initiated fromNotable Technical Challenges & SolutionsChallenge 1: Uniswap v4 Hook DeploymentUniswap v4 requires hooks to be deployed at specific CREATE2 addresses based on permission bitsSolution: Implemented a CREATE2 factory pattern with salt calculation based on hook permissions (AFTER_SWAP_FLAG = 0x40)Used iterative salt generation to find valid addresses matching permission requirementsChallenge 2: LayerZero Fee HandlingBridge operations require native ETH for LayerZero messaging feesSolution: MadePool.swappayable and forwardedmsg.valuethrough the call chain:Pool → BridgeHelper → SourceBridgeImplemented fee quoting before execution to ensure sufficient fundsChallenge 3: Cross-Chain State SynchronizationEnsuring locked tokens on source chain match minted tokens on destinationSolution: Used LayerZero's reliable messaging with enforced options and DVN (Decentralized Verifier Network) configurationImplemented event emissions for tracking lock/unlock operationsPartner TechnologiesLayerZero V2Benefit: Provides secure, reliable cross-chain messaging without requiring custom validatorsUsage: OApp pattern allows for composable cross-chain applicationsConfiguration: Set up default pathways, send/receive libraries, and DVNs for message verificationUniswap v4 SDKBenefit: Enables hook-based customization of swap behaviorUsage: IntegratedafterSwaphook to trigger bridging automatically post-swapImplementation: BridgeHook extends BaseHook and implements afterSwap callback for automatic bridgingNFC TechnologyBenefit: Enables contactless crypto payments with the same convenience as traditional NFC payments (Apple Pay, Google Pay)Usage: NFC tap triggers the swap-to-bridge flow automatically, eliminating the need for manual wallet interactionsIntegration: Connects NFC-enabled devices directly to smart contract execution via Web3 wallet integrationPayment Flow:User taps NFC-enabled device on payment terminalTerminal reads payment amount and recipient addressSmart contract executes swap (e.g., WETH → USDC) on source chainBridge hook automatically bridges tokens to recipient's preferred chainPayment completes on destination chain without recipient needing to be on source chainUse Cases:Point-of-sale crypto paymentsCross-chain merchant paymentsContactless donations and tipsAutomated payroll and vendor paymentsDevelopment WorkflowContract Development: Wrote contracts in Solidity with comprehensive error handlingTesting: Used Hardhat for local testing and testnet deploymentsDeployment: Automated deployment scripts with address verification and balance checksWiring: Configured LayerZero pathways using custom wiring scripts that set peers, libraries, and DVNsKey FeaturesNFC Crypto Payments: Contactless payment system that enables tap-to-pay functionality for cryptocurrency transactionsAutomatic Bridging: Tokens bridge automatically after swaps without user interventionFixed Swap Flow: Deterministic swap amounts (0.1 WETH → 280.9 USDC) for predictable behaviorCross-Chain Recipient: Users can specify different recipient addresses on destination chainFee Optimization: Quotes fees before execution to prevent failed transactionsOne-Tap Payments: Complete cross-chain payment flow executed with a single NFC tapMerchant-Friendly: Payment terminals can accept crypto payments that automatically bridge to merchant's preferred chain
Hackathon
ETHGlobal Buenos Aires
2025
Contributors
- Kanoopz
17 contributions