Skip to content

alchemyplatform/chain-money-wallet-apis

Repository files navigation

ChainMoney Demo

A simple payment application with server-side smart account wallets, USDC transfers, and gasless transactions on Arbitrum Sepolia. Earn interest on idle USDC balances with Aave integration.

Quick Start

1. Clone and Install

git clone <your-repo-url> cd onchain-payments npm install

2. Set Up Environment Variables

Copy .env.example to .env:

cp .env.example .env

Then fill in the required values:

Supabase (Authentication)

Database (PostgreSQL)

Alchemy (Smart Account Wallets)

  • Get from: https://dashboard.alchemy.com/
  • Create an app and a gas policy
  • ALCHEMY_API_KEY - Your Alchemy API key
  • ALCHEMY_POLICY_ID - Your Alchemy gas sponsorship policy ID
  • ⚠️ These are server-side only and never exposed to the client

Master Wallet (Transaction Signing)

  • Generate a new private key:
    node -e "console.log('0x' + require('crypto').randomBytes(32).toString('hex'))"
  • MASTER_WALLET_PRIVATE_KEY - The generated private key

⚠️ Security Note: This master wallet approach is for demo purposes only. In production, use:

  • Hardware Security Modules (HSM)
  • Multi-Party Computation (MPC) services (e.g., Fireblocks, BitGo)
  • Secure key management systems (e.g., AWS KMS, HashiCorp Vault)
  • Multi-signature setups

Different institutions have different security practices for private key management. Choose the approach that fits your security requirements.

3. Set Up Database

Push the database schema to your PostgreSQL database:

npm run db:push

This uses Drizzle Kit to read your schema from src/db/schema.ts and create the tables directly. For future schema changes, you can use Drizzle migrations to track changes over time.

4. Run the App

npm run dev

Visit http://localhost:3000

Deployment

Deploy to Vercel with one command:

npm run deploy

Or deploy to production:

npm run deploy:prod

After deploying, make sure to set up your environment variables in the Vercel dashboard:

  1. Go to your project settings → Environment Variables
  2. Add all variables from .env.example
  3. Redeploy to apply changes

How It Works

  1. Sign Up - Users create an account with email/password
  2. Smart Account - A smart account wallet is automatically created for each user
  3. Get USDC - Users get testnet USDC from Circle's faucet
  4. Send Payments - Send gasless USDC payments to other users
  5. Earn Interest - Toggle on Aave to automatically earn interest on idle USDC balances
  6. View Transactions - See all transactions on Arbitrum Sepolia

Tech Stack

  • Next.js 14 - App Router
  • Supabase - Authentication and PostgreSQL database
  • Alchemy - Smart account wallet infrastructure
  • Aave - For earning interest on the USDC
  • Arbitrum Sepolia - Testnet blockchain
  • USDC - Real testnet USDC token
  • Tailwind CSS + shadcn/ui - Styling and components

Key Features

  • ✅ No wallet installation required for users
  • ✅ One-click gasless payments
  • ✅ Server-side transaction signing
  • ✅ Real USDC on Arbitrum Sepolia testnet
  • ✅ Earn interest with Aave - simple toggle to start earning
  • ✅ Transaction history and receipts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •