npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

emailpay

v1.0.0

Published

Email-Native PYUSD Wallet using PKP wallets

Readme

EmailPay - Email-Native PYUSD Wallet

Send PYUSD payments as easily as sending an email.

EmailPay transforms every email address into a PKP (Programmable Key Pair) wallet after verification. Users can send PYUSD stablecoin payments on Ethereum Sepolia entirely via email commands—no blockchain knowledge required.


🌟 Key Features

Email-as-Wallet

  • Every verified email address represents a unique PKP wallet
  • No private keys stored server-side
  • Wallet creation and verification via OTP

Email-to-Payment Commands

Send payments by emailing simple commands to [email protected]:

SEND 10 PYUSD TO [email protected]
SEND 25.5 PYUSD TO [email protected]

Automatic Recipient Onboarding

  • If recipient doesn't have a wallet, system sends onboarding link
  • Pending payment automatically resumes after recipient verification
  • Time-limited onboarding links (configurable expiry)

Policy-Bound Security

  • Maximum per-transaction limits
  • Daily spending caps
  • Transaction expiry times
  • Idempotency to prevent double-spending

Asset & Network

  • Asset: PYUSD stablecoin only
  • Network: Ethereum Sepolia (Chain ID: 11155111)
  • Token Address: 0xCaC524BcA292aaade2DF8A05cC58F0a65B1B3bB9

🏗️ Architecture

┌─────────────────────────────────────────────────────────────┐
│                         USER FLOW                            │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│  1. User creates wallet via Web UI → Receives OTP via email │
│  2. User verifies wallet with OTP code                      │
│  3. User sends email: "SEND 10 PYUSD TO recipient@email"    │
│  4. System processes → Broadcasts transaction                │
│  5. User receives confirmation email with tx hash            │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│                    BACKEND ARCHITECTURE                      │
└─────────────────────────────────────────────────────────────┘

┌──────────────┐      ┌──────────────────┐      ┌─────────────┐
│ Gmail Poller │─────▶│ Intent Parser    │─────▶│ Policy      │
│              │      │                  │      │ Validator   │
│ • Polls inbox│      │ • Regex parsing  │      │             │
│ • Deduplicates│      │ • Extract amount │      │ • Max tx    │
│ • Parses email│      │ • Extract recipient│    │ • Daily cap │
└──────────────┘      └──────────────────┘      └─────────────┘
                                                        │
                                                        ▼
┌──────────────┐      ┌──────────────────┐      ┌─────────────┐
│ Notifier     │◀─────│ Broadcaster      │◀─────│ PKP Wallet  │
│              │      │                  │      │ Manager     │
│ • Success    │      │ • ERC-20 transfer│      │             │
│ • Failure    │      │ • Gas estimation │      │ • Create    │
│ • Onboarding │      │ • Tx broadcast   │      │ • Verify    │
│ • Confirmations│    │                  │      │ • Sign      │
└──────────────┘      └──────────────────┘      └─────────────┘
                              │
                              ▼
                    ┌──────────────────┐
                    │ Ethereum Sepolia │
                    │ PYUSD Contract   │
                    └──────────────────┘

📁 Project Structure

emailpay/
├── backend/
│   ├── config/
│   │   └── index.js              # Configuration management
│   ├── database/
│   │   └── db.js                 # JSON-based database
│   ├── services/
│   │   ├── gmailPoller.js        # Gmail API integration
│   │   ├── intentParser.js       # Command parsing & validation
│   │   ├── pkpWalletManager.js   # PKP wallet operations
│   │   ├── policyBoundSigner.js  # Policy enforcement & signing
│   │   ├── broadcaster.js        # Transaction broadcasting
│   │   ├── notifier.js           # Email notifications
│   │   └── transactionProcessor.js # Main transaction flow
│   └── index.js                  # Express server & initialization
├── frontend/
│   ├── app/
│   │   ├── page.tsx              # Home page (wallet creation)
│   │   ├── verify/page.tsx       # OTP verification
│   │   ├── onboard/page.tsx      # Recipient onboarding
│   │   ├── wallet/page.tsx       # Wallet info display
│   │   ├── layout.tsx            # Root layout
│   │   └── globals.css           # Global styles
│   ├── package.json
│   └── next.config.js
├── package.json
├── .env.example
└── README.md

🚀 Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Gmail account with API access
  • Infura or Alchemy account for Sepolia RPC
  • (Optional) Lit Protocol API keys for production PKP

Installation

  1. Clone the repository:
git clone <repository-url>
cd emailpay
  1. Install backend dependencies:
npm install
  1. Install frontend dependencies:
cd frontend
npm install
cd ..
  1. Configure environment variables:

Create .env in the root directory:

cp .env.example .env

Edit .env with your credentials:

# Ethereum Network
SEPOLIA_RPC=https://sepolia.infura.io/v3/YOUR_PROJECT_ID
CHAIN_ID=11155111
EXPLORER_BASE=https://sepolia.etherscan.io/tx/
PYUSD_ADDRESS=0xCaC524BcA292aaade2DF8A05cC58F0a65B1B3bB9

# Gmail Configuration
GMAIL_CLIENT_ID=your_gmail_client_id
GMAIL_CLIENT_SECRET=your_gmail_client_secret
GMAIL_REFRESH_TOKEN=your_gmail_refresh_token
[email protected]
GMAIL_POLL_QUERY=in:inbox newer_than:1d

# Lit Protocol
LIT_NETWORK=datil-dev
LIT_ACTION_IPFS_CID=your_lit_action_cid

# Transaction Policies
MAX_TX_AMOUNT=100
DAILY_TX_CAP=500
TX_EXPIRY_MINUTES=30

# Server
PORT=3001
FRONTEND_URL=http://localhost:3000

Create frontend/.env.local:

cd frontend
cp .env.local.example .env.local

Edit frontend/.env.local:

NEXT_PUBLIC_API_URL=http://localhost:3001

Gmail API Setup

  1. Go to Google Cloud Console
  2. Create a new project
  3. Enable Gmail API
  4. Create OAuth 2.0 credentials
  5. Download credentials and extract:
    • GMAIL_CLIENT_ID
    • GMAIL_CLIENT_SECRET
  6. Generate refresh token using OAuth playground or script
  7. Add credentials to .env

Running the Application

Development mode (both backend and frontend):

npm run dev

Or run separately:

Backend:

npm run dev:backend

Frontend (in another terminal):

npm run dev:frontend

Access the application:

  • Frontend: http://localhost:3000
  • Backend API: http://localhost:3001

📧 Usage Guide

1. Create Your Wallet

  1. Visit http://localhost:3000
  2. Enter your email address
  3. Click "Create Wallet"
  4. Check your email for the 6-digit OTP code

2. Verify Your Wallet

  1. Go to the verification page (or click link in email)
  2. Enter your email and OTP code
  3. Click "Verify Wallet"
  4. Your wallet is now active!

3. Send Payments via Email

Send an email to [email protected] with the command:

SEND 10 PYUSD TO [email protected]

Command Format:

  • SEND - Command keyword
  • <amount> - Numeric amount (e.g., 10, 25.5)
  • PYUSD - Asset (only PYUSD supported)
  • TO - Keyword
  • <recipient_email> - Valid email address

Examples:

SEND 10 PYUSD TO [email protected]
SEND 25.5 PYUSD TO [email protected]
SEND 100 PYUSD TO [email protected]

4. Receive Confirmation

You'll receive an email with:

  • Transaction hash
  • Block number
  • Etherscan explorer link
  • Sender and recipient details
  • Amount and asset

5. Recipient Onboarding

If the recipient doesn't have a wallet:

  1. They receive an onboarding email with a link
  2. Click the link to create their wallet
  3. Verify with OTP
  4. Pending payment automatically processes

🔒 Security Features

Policy Enforcement

  • Max Transaction Amount: Configurable limit per transaction
  • Daily Spending Cap: Total daily limit per wallet
  • Transaction Expiry: Time-limited transaction intents
  • Idempotency: Email deduplication prevents double-spending

PKP Wallet Security

  • No private keys stored on server
  • Policy-bound signing via Lit Protocol
  • Wallet creation requires email verification
  • OTP-based authentication

Email Security

  • Gmail OAuth 2.0 authentication
  • Refresh token rotation
  • Rate limiting on API calls
  • Email deduplication

🧪 Testing

Unit Tests

npm test

Manual Testing Flow

  1. Create Wallet:

    • Visit homepage
    • Create wallet with test email
    • Verify OTP
  2. Send Payment:

    • Email command to system
    • Check confirmation email
    • Verify transaction on Sepolia Etherscan
  3. Recipient Onboarding:

    • Send to non-existent email
    • Check onboarding email
    • Complete verification
    • Verify payment processed

Test Accounts

Use temporary email services for testing:


🛠️ API Reference

Backend Endpoints

Create Wallet

POST /api/wallet/create
Content-Type: application/json

{
  "email": "[email protected]"
}

Verify Wallet

POST /api/wallet/verify
Content-Type: application/json

{
  "email": "[email protected]",
  "otpCode": "123456"
}

Get Wallet Info

GET /api/wallet/:email

Onboard Recipient

POST /api/onboard
Content-Type: application/json

{
  "token": "onboarding_token"
}

Get Transaction Status

GET /api/transaction/:txId

📊 Database Schema

The system uses a simple JSON file database (data/db.json):

{
  "users": {
    "[email protected]": {
      "email": "[email protected]",
      "pkpPublicKey": "0x...",
      "pkpEthAddress": "0x...",
      "otpCode": "123456",
      "verified": true,
      "createdAt": "2024-01-01T00:00:00.000Z",
      "verifiedAt": "2024-01-01T00:05:00.000Z"
    }
  },
  "transactions": {
    "tx-uuid": {
      "txId": "tx-uuid",
      "senderEmail": "[email protected]",
      "recipientEmail": "[email protected]",
      "amount": 10,
      "asset": "PYUSD",
      "txHash": "0x...",
      "status": "completed"
    }
  },
  "pendingTransactions": {},
  "processedEmails": ["email-id-1", "email-id-2"],
  "dailySpending": {
    "[email protected]:2024-01-01": 50.5
  }
}

🚧 Roadmap

Phase 1 (Current)

  • ✅ Email-based wallet creation
  • ✅ OTP verification
  • ✅ PYUSD transfers via email
  • ✅ Recipient onboarding
  • ✅ Policy enforcement

Phase 2 (Future)

  • [ ] Support for 0x address recipients
  • [ ] Multiple asset support (USDC, USDT)
  • [ ] Transaction history in UI
  • [ ] Webhook notifications
  • [ ] Production Lit Protocol integration

Phase 3 (Future)

  • [ ] Multi-chain support
  • [ ] Batch transactions
  • [ ] Scheduled payments
  • [ ] Payment requests
  • [ ] Mobile app

🐛 Troubleshooting

Gmail Polling Not Working

  • Verify Gmail API credentials
  • Check refresh token validity
  • Ensure Gmail API is enabled in Google Cloud Console
  • Check GMAIL_POLL_QUERY filter

Transactions Not Broadcasting

  • Verify Sepolia RPC endpoint
  • Check PYUSD contract address
  • Ensure wallet has ETH for gas (in production)
  • Check transaction policies

OTP Not Received

  • Check spam folder
  • Verify Gmail sending permissions
  • Check email service logs
  • Ensure correct email format

Frontend Not Connecting to Backend

  • Verify NEXT_PUBLIC_API_URL in frontend .env.local
  • Check backend is running on correct port
  • Verify CORS settings

📝 Environment Variables Reference

| Variable | Description | Example | |----------|-------------|---------| | SEPOLIA_RPC | Ethereum Sepolia RPC URL | https://sepolia.infura.io/v3/... | | CHAIN_ID | Ethereum chain ID | 11155111 | | PYUSD_ADDRESS | PYUSD token contract address | 0xCaC524BcA292aaade2DF8A05cC58F0a65B1B3bB9 | | GMAIL_CLIENT_ID | Gmail OAuth client ID | From Google Cloud Console | | GMAIL_CLIENT_SECRET | Gmail OAuth client secret | From Google Cloud Console | | GMAIL_REFRESH_TOKEN | Gmail OAuth refresh token | Generated via OAuth flow | | GMAIL_USER | Gmail account email | [email protected] | | MAX_TX_AMOUNT | Max PYUSD per transaction | 100 | | DAILY_TX_CAP | Max PYUSD per day per wallet | 500 | | TX_EXPIRY_MINUTES | Transaction intent expiry | 30 |


🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License.


🙏 Acknowledgments

  • Lit Protocol for PKP wallet infrastructure
  • PayPal for PYUSD stablecoin
  • Ethereum for blockchain infrastructure
  • Gmail API for email integration

📞 Support

For issues and questions:


⚠️ Disclaimer

This is a demonstration project running on Ethereum Sepolia testnet. Do not use with real funds or in production without proper security audits and testing.

PYUSD on Sepolia is for testing purposes only.


Built with ❤️ for the future of email-native payments