Skip to content

Wutche/inflow

Repository files navigation

Inflow

Inflow Logo

The Bridge Between Ecosystems & The Future of Monetized APIs

Stacks USDCx Next.js Sepolia x402

Problem: Liquidity Fragmentation & AI Agent Payments. Solution: A Cross-Chain, x402-compliant invoicing protocol.

Inflow bridges USDC between Ethereum and Bitcoin-secured Stacks using Circle's xReserve, enabling seamless cross-chain invoicing with instant settlement. It leverages the novel x402 protocol to turn API endpoints into pay-per-use services, creating the first truly monetizable, spam-proof developer infrastructure on Stacks.


🎯 Challenge Integration: Programming USDCx on Stacks

Inflow directly implements Circle's xReserve protocol to facilitate bi-directional USDC bridging between Ethereum Sepolia and Stacks Testnet.

Bridge Architecture

Ethereum → Stacks (Minting USDCx)

The bridge uses the depositToRemote function on the xReserve contract to burn USDC on Ethereum and mint USDCx on Stacks:

Diagram

Implementation: src/hooks/useBridge.ts (Lines 409-504)

  • Function Selector: 0xfaadb53b (depositToRemote)
  • Parameters: Amount (uint256), Destination Domain (Stacks = custom ID), Recipient (Stacks address as bytes32)
  • Gas Optimization: 300,000 gas limit for cross-chain bridging

Stacks → Ethereum (Burning USDCx)

Return flow uses the burn function on the usdcx-v1 Clarity contract:

Diagram

Implementation: src/hooks/useBridge.ts (Lines 509-593)

  • Contract: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.usdcx-v1
  • Post Conditions: Enforces token burn via Clarity's ft-postcondition
  • Address Encoding: Ethereum addresses converted to 32-byte buffers

💡 Innovation: The x402 Payment Protocol

Inflow introduces HTTP 402 (Payment Required) as a native blockchain monetization layer. Every API call to create invoices, fetch data, or verify payments requires a micro-payment in STX.

How x402 Works

Diagram

Implementation: src/lib/x402.ts + src/app/api/v1/invoices/route.ts

Pricing Model (Pay-Per-Action)

Endpoint Action Cost
POST /api/v1/invoices Create Invoice 0.001 STX
GET /api/v1/invoices/:id Fetch Invoice 0.0005 STX
POST /api/v1/verify Verify Payment 0.0002 STX

Why This Matters: Traditional APIs rely on API keys, rate limits, and centralized authentication. x402 makes every endpoint self-sovereign and spam-resistant without needing databases or OAuth flows.


🛠️ Tech Stack & Architecture

Frontend

  • Next.js 16 (App Router with server actions)
  • TypeScript (Strict mode, Zod validation)
  • Tailwind CSS v4 (Custom design system)
  • Framer Motion (Premium animations)
  • Shadcn UI (Composable components)

Blockchain Integration

  • @stacks/connect - Stacks wallet connections (Hiro, Xverse)
  • @stacks/wallet-sdk - Key management
  • x402-stacks - Payment verification protocol
  • Phantom/MetaMask - Ethereum wallet support

Testing & Quality

  • Vitest - Unit testing
  • Playwright - E2E testing
  • ESLint - Code quality

Smart Contracts

  • xReserve (Ethereum): 0x... (Sepolia)
  • USDCx (Stacks): ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.usdcx-v1

🚀 Installation & Setup

Prerequisites

Environment Variables

Create a .env.local file in the root:

# x402 Configuration
X402_RECEIVE_ADDRESS=ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
X402_NETWORK=testnet
X402_FACILITATOR_URL=https://x402-backend-7eby.onrender.com

# Development Only (bypasses blockchain verification)
X402_BYPASS_VERIFICATION=true

# Optional: Testing Private Key (DO NOT USE IN PRODUCTION)
STACKS_PRIVATE_KEY=your_testnet_private_key_here

# App Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000

Installation

# Clone the repository
git clone https://github.com/yourusername/inflow-app.git
cd inflow-app

# Install dependencies
npm install

# Run development server
npm run dev

Visit http://localhost:3000 and connect your wallets.

Testing the Bridge

  1. Navigate to /dashboard/bridge
  2. Connect both Ethereum (Phantom/MetaMask) and Stacks (Hiro/Xverse) wallets
  3. For ETH → Stacks:
    • Enter amount and recipient Stacks address
    • Approve USDC spending
    • Click "Bridge to Stacks"
  4. For Stacks → ETH:
    • Enter amount and recipient Ethereum address
    • Confirm transaction in Stacks wallet

Testing x402 API

Visit the demo at /dashboard/x402-demo or use the CLI:

# Run the verification script
npm run test

🏆 Why Inflow Wins: Real-World Impact

Inflow doesn't just bridge assets—it bridges business models. By combining Circle's institutional-grade xReserve infrastructure with the x402 protocol, we've created the foundation for a Service-as-a-Protocol economy on Stacks.

Traditional Web2 APIs require credit cards, complex authentication, and centralized billing. Traditional Web3 APIs rely on off-chain API keys with subscriptions. Inflow's x402 approach makes every endpoint a self-contained economic unit: pay instantly in STX, access immediately, no middleman.

This unlocks:

  • Spam-Proof Infrastructure: No more rate-limiting hacks—economic cost prevents abuse
  • Micropayment Economics: Pay fractions of a cent per API call, enabling usage-based pricing
  • AI Agent Commerce: LLMs with wallets can autonomously pay for services (invoice generation, data access)
  • Bitcoin-Secured Finality: Every payment inherits Stacks' PoX security model

Inflow proves that programmable money meets programmable infrastructure—and that future is built on USDCx and Stacks.


🗺️ Roadmap

Advanced Commerce (Q1 2026)

  • Entire Design Overhaul: A fresh, premium aesthetic to match the future of finance.
  • Recurring Subscriptions: Enabling SaaS & newsletters to bill in USDCx.
  • Escrow Milestones: "Trustless" payments for freelancers (funds held until work is approved).

The Fiat Bridge (Q2 2026)

  • Direct-to-Bank Payouts: One-click off-ramping from USDCx directly to local fiat currencies (NGN, KES, USD).
  • Stablecoin-to-Bills: Pay real-world utilities directly from the Inflow dashboard.

Ecosystem Expansion (Q3 2026)

  • SDK Development: Empowering other developers to build on Inflow's infrastructure.
  • DAO Payroll Integration: Batch processing for organizations to pay huge teams in one click.
  • Mainnet Launch: Full deployment alongside the Stacks Nakamoto upgrade.

📚 Documentation

📄 License

MIT License - See LICENSE file for details.


Built with ❤️ by Inflow Contributors on Stacks | Live Demo | GitHub

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages