Pay like Venmo, invest like a pro. Instant @handle payments + auto-rebalancing portfolios.
StackFlow Overview
StackFlow is a next-generation Web3 financial super-app that combines instant blockchain payments with intelligent portfolio investing, all powered by PYUSD stablecoin on Arbitrum. Think of it as โApple Pay meets Robinhoodโ for crypto โ making both payments and investing simple, fast, and accessible.
๐ฏ Core Problem Solved
Traditional crypto wallets are complex and intimidating. Users need to remember long hexadecimal addresses, manage gas fees, and canโt easily invest in diversified crypto portfolios.
StackFlow solves this by:
Simplifying payments with human-readable handles (@username@pyusd) instead of wallet addresses
Democratizing investing through expert-curated, auto-rebalancing crypto portfolios
Reducing barriers with a beautiful, intuitive UX inspired by Apple Pay and Paytm
Ensuring security with enterprise-grade AES-256 encryption and server-side transaction signing
๐ณ Payment Features Smart Blockchain Payments
Create unique payment handles like @alice@pyusd or @bob@pyusd
Send PYUSD to anyone using their handle (no need to remember 0x... addresses)
Generate QR codes for instant receiving
Real-time transaction tracking with blockchain explorer integration
Automatic wallet generation on signup (users never see private keys)
Encrypted private key storage in Supabase with AES-256 encryption
Server-side transaction signing for maximum security
Payment Links
A shareable link system that enables users to create custom payment requests โ similar to Venmo or PayPal links, but fully on-chain with PYUSD.
How it works:
Create a link with amount, description, and optional expiry
Get a shareable URL (e.g., StackFlow.app/pay/abc123) or QR code
Recipients click, connect wallet, and pay instantly
Track real-time payment status (paid, pending, expired)
Key capabilities:
Fixed or flexible payment amounts
Custom memos/descriptions (e.g., โCoffee โโ, โRent splitโ)
Expiration and one-time/reusable links
Dashboard view for all created links with payment history
Use cases: Freelancers, small businesses, event organizers, friends splitting bills, and donations โ all simplified with one-click blockchain payments.
Key Payment Capabilities
Send PYUSD via handles or traditional wallet addresses
Instant transfers on Arbitrum network (low gas fees)
Transaction history with timestamp, amount, and blockchain confirmation
Copy wallet address with one tap
Download payment QR codes
Balance tracking in real-time
๐ Portfolio Investment Features Expert-Curated Portfolios
StackFlow offers a range of professionally designed portfolios across different risk levels and market sectors โ from stable, blue-chip blends to high-growth themes like AI, DeFi, and Layer 2 ecosystems.
Investment Capabilities
One-click investing with PYUSD (minimum 10 PYUSD)
Live price tracking via Pyth Network oracles
Automatic portfolio rebalancing (weekly or monthly)
Share-based accounting for transparent value tracking
Real-time performance and P/L monitoring
Withdraw anytime at current market value
Interactive charts and risk indicators
๐๏ธ Technical Architecture Frontend Stack
React 18.3 + TypeScript for type-safe development
Vite for lightning-fast builds and HMR
TailwindCSS 3.4 for responsive, utility-first styling
Framer Motion for smooth 60fps animations
React Router for client-side navigation
Recharts for interactive portfolio charts
Lucide React for modern iconography
Backend & Database
Supabase for authentication, PostgreSQL database, and real-time subscriptions
Row Level Security (RLS) policies protecting user data
Automatic timestamp tracking and audit trails
Helper functions for complex queries
Blockchain Layer
ethers.js 6.x for Ethereum/Arbitrum interaction
Arbitrum Sepolia testnet (production ready for mainnet)
PYUSD ERC-20 token integration
Pyth Network price oracles via Hermes API
Smart contracts: PortfolioManager.sol and PythPriceOracle.sol
Server-side transaction signing (private keys never exposed to client)
Database Schema
Payment Tables:
wallets โ User wallet addresses and encrypted private keys
handles โ Unique payment handle system (@username@pyusd)
transactions โ Complete transaction history with blockchain references
payment_links โ Generated payment links with amount, expiry, and status tracking
Investment Tables:
portfolios โ Portfolio definitions with token allocations
user_investments โ User portfolio holdings with share tracking
portfolio_performance โ Historical NAV and performance metrics
rebalance_history โ Audit trail of all rebalancing events
token_prices โ Cached Pyth price feed data
investment_transactions โ Complete investment/withdrawal log
๐ Security Architecture Multi-Layer Security
Client-Side: No private keys ever transmitted or stored in browser
Transport: All API calls over HTTPS with Supabase authentication
Storage: AES-256 encryption for private keys in database
Database: Row Level Security ensures users only see their own data
Signing: All transactions signed server-side via Supabase Edge Functions
Validation: Input sanitization and validation on all user inputs
Authentication: Supabase Auth with email/password and session management
๐จ User Experience Design Philosophy
Apple Pay-inspired clean, minimalist interface
Paytm-influenced color scheme with gradients and glassmorphism
Dark mode throughout for reduced eye strain
Smooth animations with Framer Motion (fade, slide, scale transitions)
Mobile-first responsive design with bottom navigation
Skeleton loaders for perceived performance
Empty state components with helpful CTAs
Toast notifications for user feedback
Key UX Features
One-click actions (send, invest, withdraw, request)
Instant visual feedback on all interactions
Real-time balance updates
Live price tickers
Interactive charts with tooltips
Copy-to-clipboard with confirmation
QR code generation and download
Protected routes with automatic redirects
Loading states during async operations
๐ฑ User Journey New User Flow
Sign up with email, password, and unique handle
System auto-generates secure EVM wallet
Private key encrypted and stored securely
Redirected to dashboard showing balance and handle
Can immediately receive PYUSD via QR code or handle
Fund wallet to start sending payments or investing
Payment Flow
Click โSendโ from dashboard
Enter recipient handle (@alice@pyusd) or wallet address
Enter PYUSD amount
Confirm transaction
System signs transaction server-side
Broadcast to Arbitrum network
Real-time confirmation with blockchain link
Payment Link Flow
Create a payment link from the dashboard
Add amount, description, and expiry (optional)
Share the link or QR code
Recipient pays instantly using PYUSD
View payment status and history in real-time
Investment Flow
Navigate to โInvestโ tab
Explore curated portfolios with live prices and categories
Choose risk level and amount
Confirm investment to receive proportional portfolio shares
Track performance in โMy Investmentsโ tab
๐ Key Innovations
Handle System: First PYUSD wallet with social-style handles for easy payments
Payment Links: Shareable blockchain payment requests for individuals and businesses
Unified App: Payments + investing in one seamless experience
Auto-Rebalancing: Smart contracts automatically maintain target allocations
Live Pricing: Pyth Network integration for real-time, accurate token prices
Share Model: Fair value distribution with transparent NAV calculation
Zero Custody: Users maintain full ownership via encrypted key storage
Mobile-First: Optimized for smartphone use with touch-friendly UI
๐ฏ Target Audience
Crypto newcomers who want a simple payment experience
Freelancers and small businesses seeking easy, on-chain payments
Passive investors wanting diversified exposure without manual management
Mobile users needing quick payments and portfolio tracking on-the-go
International users leveraging stablecoins for cross-border payments
๐ ๏ธ How It's Made ๐ Partner Technologies ๐ช PYUSD (PayPal USD) - The Foundation
PYUSD is the core payment rail powering every transaction in our app. We chose PYUSD because it combines the stability of a regulated stablecoin with the speed and efficiency of blockchain technology.
Why PYUSD?
Stability: Being backed by PayPal and pegged 1:1 to USD, users can pay and invest without worrying about price volatility Trust Factor: PayPal's brand recognition makes crypto accessible to mainstream users who might be intimidated by volatile tokens Arbitrum Native: PYUSD's deployment on Arbitrum gives us lightning-fast transactions (15-30 seconds) with minimal gas fees (pennies instead of dollars) Regulatory Compliance: As a regulated stablecoin, PYUSD provides peace of mind for users concerned about legal compliance How We Use PYUSD:
Payment System: Every transaction - whether sending to a friend via @handle or paying via QR code - uses PYUSD as the base currency. Users maintain PYUSD balances, send PYUSD to each other, and receive PYUSD payments.
Implementation: pyusd.ts contains PYUSD contract integration Transfer logic: transfer.ts handles all PYUSD movements Portfolio Investments: All six curated portfolios accept PYUSD as the investment currency. Users invest PYUSD to get portfolio shares, and withdraw back to PYUSD.
Smart contract: PortfolioManager.sol manages PYUSD deposits and withdrawals Investment service: portfolio.ts orchestrates PYUSD-to-shares conversions Payment Links: Our Venmo-style payment request system uses PYUSD exclusively, making it easy for anyone to create shareable payment links.
Payment link handler: paymentLinks.ts processes PYUSD transfers Public payment page: PaymentLink.tsx displays amounts in PYUSD The Impact: PYUSD transforms our app from just another volatile crypto wallet into a practical financial tool. Users can confidently hold balances, make payments, and invest knowing their base asset won't lose 20% overnight. It's the perfect bridge between traditional finance (stability, trust) and Web3 (speed, transparency, low fees).
๐ Pyth Network - The Price Oracle Backbone
Pyth Network provides the real-time, institutional-grade price data that powers our entire portfolio investment system. Without Pyth, we couldn't offer accurate valuations, fair pricing, or automated rebalancing.
Why Pyth Network?
Institutional Quality: Pyth aggregates price data from 90+ first-party publishers (major exchanges, market makers, trading firms) - the same data professional traders use Low Latency: Sub-second price updates ensure our portfolio NAV (Net Asset Value) reflects current market conditions 18+ Token Coverage: Pyth supports every asset in our portfolios - from Bitcoin and Ethereum to newer tokens like PEPE and STRK Arbitrum Integration: Native support on Arbitrum means we can verify prices on-chain when needed for trustless smart contract operations Confidence Intervals: Pyth includes confidence metrics with each price, helping us detect unreliable data and protect users How We Use Pyth:
Live Portfolio Valuation: When users browse portfolios on the Invest page, they see real-time values calculated using live Pyth prices. A portfolio with 60% BTC and 40% ETH displays its current USD value based on up-to-the-second market prices.
Price fetching: pyth.ts connects to Pyth's Hermes API Portfolio value calculation: portfolio.ts uses Pyth prices to compute NAV Visual display: PortfolioCard.tsx shows live-updated values Fair Investment Pricing: When a user invests 100 PYUSD into a portfolio, Pyth prices determine how many shares they receive. If the portfolio is worth $10,000 and has 1,000 shares, the NAV per share is $10. The user gets 10 shares. This ensures everyone pays fair market value.
Smart contract oracle: PythPriceOracle.sol fetches on-chain Pyth prices Share calculation: PortfolioManager.sol uses Pyth NAV for minting shares Performance Tracking: Historical Pyth prices are cached in our database to power the performance charts. Users can see if their portfolio is up 5% or down 2% based on actual price movements.
Price caching: Supabase token_prices table stores Pyth data with timestamps Chart rendering: PerformanceChart.tsx displays NAV history Auto-Rebalancing Triggers: Our smart contracts use Pyth prices to detect when a portfolio drifts from its target allocation. If a portfolio should be 50% BTC / 50% ETH but BTC pumps to 60%, Pyth prices trigger an automatic rebalance.
Rebalance detection: rebalance.ts monitors price-based drift On-chain execution: PortfolioManager.sol rebalances using Pyth prices Implementation Highlights:
We use Pyth's Hermes API for off-chain price fetching (faster, free) and Pyth's on-chain contracts for critical operations (trustless, verifiable).
Hermes API Integration: pyth.ts fetches all 18 token prices in a single batch request every 5 seconds Price ID Mapping: We maintain a mapping of token symbols to Pyth price feed IDs (e.g., BTC โ 0xe62df6...) Client-Side Caching: Prices are cached for 5 seconds to reduce API calls while maintaining real-time feel Database Storage: token_prices table in Supabase stores historical Pyth data for charts and analytics Smart Contract Verification: PythPriceOracle.sol verifies Pyth signatures on-chain for high-stakes operations The Impact: Pyth Network transforms our portfolios from static allocations into living, breathing investment products. Users get:
Accurate portfolio values that update as markets move Fair pricing when investing or withdrawing (no front-running or stale prices) Transparent performance tracking based on real market data Trustless auto-rebalancing driven by verifiable price feeds Without Pyth, we'd be relying on centralized APIs that could go down, provide stale data, or be manipulated. With Pyth, we have institutional-grade infrastructure that's decentralized and tamper-proof.
๐๏ธ Core Technology Stack Frontend Architecture:
Built with React and TypeScript for type safety and modern component patterns. Styling: TailwindCSS Animations: Framer Motion handles all smooth transitions - page fades, modal slides, button scales Charts: Recharts renders the interactive portfolio performance graphs and allocation pie charts Routing: React Router v6
Backend & Database:
Supabase serves as our backend-as-a-service, providing authentication, database, and serverless functions all in one platform.
PostgreSQL Database: Stores user accounts, wallet addresses, encrypted private keys, transactions, portfolios, and investment history Row Level Security (RLS): Database policies ensure users can only access their own data - no user can query another's wallet or transactions Supabase Auth: Handles email/password authentication with session management Real-time Subscriptions: Balance updates and transaction confirmations push to the UI instantly Edge Functions: Server-side transaction signing happens in Supabase functions where private keys are decrypted securely Key files: supabase.ts (client setup), supabase_schema.sql (database schema), supabase_portfolio_schema.sql (investment tables)
Blockchain Layer:
Currently deployed on the Sepolia testnet for development and testing, with plans to migrate to Arbitrum for production due to its speed and low-cost scalability.
All blockchain interactions are handled through ethers.js v6, powering wallet creation, transaction signing, and contract execution.
Smart Contracts: PortfolioManager.sol manages investments and withdrawals, while PythPriceOracle.sol integrates live price feeds from Pyth.
Wallets: Auto-generated EVM wallets are created on signup using ethers.Wallet.createRandom().
Security: Transactions are signed server-side, ensuring private keys never leave the backend.
PYUSD Integration: All payments and portfolio operations use the ERC-20 standard PYUSD token for seamless value transfers.
๐ฏ Notable Architecture Decisions
Instead of forcing users to remember 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb, we built a UPI-style handle system. Users create unique handles like alice@pyusd during signup, stored in the handles table. When sending money, recipients are resolved via handle lookup.
Implementation: handle.ts resolves handles to addresses, SendModal.tsx accepts both handles and addresses
Private keys are generated server-side during signup, encrypted with AES-256 using a key derived from the user's password, and stored in Supabase. They're NEVER sent to the client. When a transaction is needed, the frontend sends transaction parameters to a Supabase Edge Function, which decrypts the key, signs the transaction, and broadcasts it.
Implementation: wallet.ts (wallet generation), transfer.ts (server-side signing)
Inspired by mutual fund shares, each portfolio tracks total shares outstanding and NAV. When you invest, you receive shares proportional to current NAV. When you withdraw, your shares are burned and you get PYUSD based on current value. This handles variable portfolio values elegantly.
Implementation: PortfolioManager.sol (share minting/burning), portfolio.ts (share value calculations)
To make the app feel instant despite 15-30 second blockchain confirmations, we optimistically update balances and transaction lists immediately, then reconcile with actual blockchain state once confirmed. If a transaction fails, we roll back the optimistic update.
Implementation: WalletContext.tsx (balance management), transactions.ts (transaction status tracking)
Instead of making 18 separate API calls to Pyth for each token, we batch all price IDs into a single Hermes API request. This reduces latency from 3-4 seconds to 200ms and refreshes every 5 seconds for real-time feel.
Implementation: pyth.ts (batch price fetching with 5-second client-side cache)
๐ Data Flow Example: Making an Investment User navigates to /invest and browses portfolios Frontend fetches portfolio definitions from Supabase portfolios table Pyth prices for all 18 tokens are batch-fetched via Hermes API Current NAV is calculated for each portfolio (allocation ร prices) User clicks "Invest" on "Bluechip Blend" portfolio Investment modal shows breakdown (60% BTC, 40% ETH) with live values User enters 100 PYUSD and confirms Frontend calls investInPortfolio() service function Service calculates shares to mint based on current NAV from Pyth prices Transaction parameters sent to Supabase Edge Function Edge Function decrypts user's private key (server-side) Approves PYUSD spending for PortfolioManager contract Calls invest() function on PortfolioManager smart contract Smart contract verifies Pyth prices on-chain, mints shares Transaction confirmed on Arbitrum (~20 seconds) Database updated with new investment record User's "My Investments" tab shows new holding with current value All of this happens seamlessly with PYUSD as the currency and Pyth as the price oracle.
๐จ User Experience Highlights Design Philosophy: We took inspiration from Apple Pay (clean minimalism) and Paytm (vibrant gradients) to create a premium dark-mode interface that feels more like a fintech app than a crypto wallet.
๐ Security Architecture Multi-Layer Security:
Client-Side: No sensitive data in browser - private keys never leave the server Transport: All communication over HTTPS with Supabase authentication tokens Storage: AES-256 encryption for private keys, salted and password-derived encryption keys Database: Row Level Security policies prevent unauthorized data access Smart Contracts: On-chain Pyth price verification prevents price manipulation Validation: Input sanitization on all user inputs (amounts, handles, addresses) The combination of server-side key management, RLS policies, and Pyth's cryptographically-signed prices creates a secure foundation users can trust.
๐ Performance Optimizations Price Caching: 5-second TTL on Pyth prices reduces API calls by 90% Database Indexing: Indexed queries on wallets, handles, and transactions for sub-100ms responses Lazy Loading: Pages and components load on-demand via React Router Optimistic Updates: UI responds instantly while blockchain confirms in background Batch Operations: Single Pyth API call fetches all 18 token prices simultaneously ๐ The Result A production-ready Web3 fintech app that combines:
PYUSD's stability for practical everyday use Pyth's price feeds for accurate, trustless portfolio valuations Instant settlement Modern UX that feels like Venmo meets Robinhood Bank-grade security with full user custody Users get the best of both worlds - the simplicity and reliability of traditional fintech with the transparency and ownership of Web3.

