The Bridge Between Ecosystems & The Future of Monetized APIs
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.
Inflow directly implements Circle's xReserve protocol to facilitate bi-directional USDC bridging between Ethereum Sepolia and Stacks Testnet.
The bridge uses the depositToRemote function on the xReserve contract to burn USDC on Ethereum and mint USDCx on Stacks:
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
Return flow uses the burn function on the usdcx-v1 Clarity contract:
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
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.
Implementation: src/lib/x402.ts + src/app/api/v1/invoices/route.ts
| 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.
- 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)
@stacks/connect- Stacks wallet connections (Hiro, Xverse)@stacks/wallet-sdk- Key managementx402-stacks- Payment verification protocol- Phantom/MetaMask - Ethereum wallet support
- Vitest - Unit testing
- Playwright - E2E testing
- ESLint - Code quality
- xReserve (Ethereum):
0x...(Sepolia) - USDCx (Stacks):
ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.usdcx-v1
- Node.js 20+ and npm
- Wallets:
- Ethereum: Phantom or MetaMask
- Stacks: Hiro Wallet or Xverse
- Testnet Tokens:
- Sepolia ETH (for gas): Sepolia Faucet
- Sepolia USDC: Circle Faucet
- Stacks STX: Stacks Faucet
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# Clone the repository
git clone https://github.com/yourusername/inflow-app.git
cd inflow-app
# Install dependencies
npm install
# Run development server
npm run devVisit http://localhost:3000 and connect your wallets.
- Navigate to
/dashboard/bridge - Connect both Ethereum (Phantom/MetaMask) and Stacks (Hiro/Xverse) wallets
- For ETH → Stacks:
- Enter amount and recipient Stacks address
- Approve USDC spending
- Click "Bridge to Stacks"
- For Stacks → ETH:
- Enter amount and recipient Ethereum address
- Confirm transaction in Stacks wallet
Visit the demo at /dashboard/x402-demo or use the CLI:
# Run the verification script
npm run testInflow 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.
- 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).
- 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.
- 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.
MIT License - See LICENSE file for details.
Built with ❤️ by Inflow Contributors on Stacks | Live Demo | GitHub
