AegisAEGIS
MoonPay

MoonPay Integration

Fiat on-ramp for AI agent wallets β€” fund agents with credit card or bank transfer. No crypto needed to get started.

Why MoonPay for Agents?

πŸ’³

Fiat-to-Crypto Bridge

Fund agents with credit card, debit card, or bank transfer

πŸ–₯️

CLI + Web Widget

Developer CLI for automation, web widget for user-facing flows

πŸͺ™

Multi-Token Support

Buy USDC, ETH, SOL across Ethereum, Base, Solana, Polygon

πŸ”’

KYC Compliant

Regulatory-compliant on-ramp β€” handles identity verification


What Aegis Uses MoonPay For

Agent Wallet Funding

Generate funding URLs and CLI commands to top up agent wallets from fiat currency.

CLI Wallet Management

Check if MoonPay CLI is installed, list managed wallets, and initiate purchases programmatically.

Zero-Crypto Onboarding

Deploy and fund agents without needing any existing cryptocurrency holdings.


Use Cases

\uD83D\uDE80

Agent Onboarding

Fund new agent wallets without existing crypto. Credit card to USDC in one step.

mp buy --currency usdc --wallet 0x...

\uD83D\uDD04

Budget Top-Up

Replenish agent budgets via fiat when funds run low. Triggered by budget policy alerts.

budget alert β†’ MoonPay URL β†’ funded

\uD83C\uDFE2

Enterprise Deployment

Fund entire agent fleets via corporate credit card. No crypto treasury required.

fleet.agents.map(a => fundUrl(a.addr))

\uD83D\uDEE0\uFE0F

Developer Experience

Quick testnet-to-mainnet transition. Same workflow, real funds.

mp buy β†’ agent funded β†’ deploy


Embedded On-Ramp Widget

When MOONPAY_SECRET_KEYis configured, the buy widget opens inline in the Aegis dashboard β€” operators never leave the app. Without it, falls back to opening MoonPay in a new tab.

Generate a signed buy widget URL
import { getMoonPayBuyUrl } from "@aegis-ows/integrations";

const url = getMoonPayBuyUrl({
  walletAddress: "2G55SdspdgSLcrXm3ZcfSHuDhvuhXtQLWqf1zVbAYCcq",
  currencyCode: "sol",           // "sol", "usdc", "eth"
  baseCurrencyCode: "usd",       // Fiat currency
  baseCurrencyAmount: "50",      // Pre-fill $50
  externalTransactionId: "aegis-data-miner-1234",
});

// With secret key: URL is HMAC-signed for embedded iframe mode
// Without: plain URL opens in new tab
Dashboard API route
// POST /api/moonpay/sign
const res = await fetch("/api/moonpay/sign", {
  method: "POST",
  body: JSON.stringify({
    walletAddress: agentId,
    currencyCode: "usdc",
    externalTransactionId: `aegis-${agentId}-${Date.now()}`,
  }),
});
const { url } = await res.json();
// url is ready for iframe src or window.open()

Off-Ramp (Cash Out Profits)

Agents that earn more than they spend can cash out to the operator's bank account. The β€œWithdraw Profits” card only appears when an agent has positive P&L.

Generate a sell widget URL
import { getMoonPaySellUrl } from "@aegis-ows/integrations";

const url = getMoonPaySellUrl({
  walletAddress: "2G55Sds...",
  currencyCode: "usdc",          // Crypto to sell
  baseCurrencyCode: "usd",       // Fiat to receive
  quoteCurrencyAmount: "100",    // Amount of crypto to sell
  externalTransactionId: "aegis-sell-analyst-5678",
});
// Opens MoonPay sell flow β†’ crypto leaves wallet β†’ fiat hits bank

Revenue isn't trapped in crypto

Off-ramping makes agent economies feel like a real business. Operators can withdraw profits to their bank without touching an exchange.


Token Swaps

Agent holds SOL but needs to pay in USDC? Swap in-flow via MoonPay β€” no DEX interaction needed.

Generate a swap URL
import { getMoonPaySwapUrl } from "@aegis-ows/integrations";

const url = getMoonPaySwapUrl({
  walletAddress: "2G55Sds...",
  fromCurrencyCode: "sol",
  toCurrencyCode: "usdc",
});
// Opens MoonPay swap widget

Transaction Tracking

Track buy/sell/swap transactions in real-time. Requires MOONPAY_SECRET_KEY.

Query transaction status
import { getMoonPayTransaction } from "@aegis-ows/integrations";

const tx = await getMoonPayTransaction("aegis-data-miner-1234");
// Returns:
// {
//   id: "tx_abc...",
//   status: "completed",        // waitingPayment | pending | completed | failed
//   cryptoAmount: "0.5",
//   baseCurrencyAmount: "50",
//   baseCurrency: "usd",
//   currency: "sol",
//   walletAddress: "2G55Sds...",
//   createdAt: "2024-01-15T10:30:00Z"
// }
Dashboard API
// GET /api/moonpay/transactions?externalId=aegis-data-miner-1234
// Returns MoonPayTransaction object
// Status polling: dashboard component polls every 10s until terminal state

Webhooks

MoonPay sends real-time webhook events when transactions complete. Aegis validates the signature and logs to the agent activity feed.

Webhook handler
// POST /api/moonpay/webhook
// Headers: moonpay-signature-v2: <HMAC-SHA256 signature>

// Events handled:
// transaction_completed β†’ log success, trigger balance refresh
// transaction_failed    β†’ log failure, notify operator
// transaction_updated   β†’ log status change

// Signature validated using MOONPAY_WEBHOOK_KEY
// Invalid signatures return 401
Webhook validation
import { validateMoonPayWebhook } from "@aegis-ows/integrations";

const payload = validateMoonPayWebhook(rawBody, signatureHeader);
if (!payload) {
  // Invalid signature β€” reject
}
// payload.type: "transaction_completed" | "transaction_failed" | ...
// payload.data: transaction details

Currencies API

Dynamically query which tokens MoonPay supports instead of hardcoding. Cached for 1 hour.

Fetch supported currencies
import { getMoonPayCurrencies } from "@aegis-ows/integrations";

const currencies = await getMoonPayCurrencies();
// With API key: fetches from MoonPay /v3/currencies
// Without: returns hardcoded [SOL, USDC, ETH]

// Each currency:
// { code: "sol", name: "Solana", minBuyAmount: 0.1, maxBuyAmount: 30000,
//   isSellSupported: true, ... }

Geo Availability

Check if MoonPay is available in the operator's country before showing funding options.

Check availability
import { checkMoonPayAvailability } from "@aegis-ows/integrations";

const availability = await checkMoonPayAvailability();
// { isAllowed: true, isBuyAllowed: true, isSellAllowed: true, alpha2: "US" }

// Without API key: returns optimistic default (always allowed)
// With API key: checks MoonPay /v4/ip_address endpoint

URL Generation

Generate funding options for an agent wallet
import { getMoonPayFundingOptions } from "@aegis-ows/integrations";

const options = getMoonPayFundingOptions("0x1234...");

// Returns:
// {
//   provider: "moonpay",
//   command: "mp buy --currency usdc --wallet 0x1234...",
//   url: "https://www.moonpay.com/buy/usdc?walletAddress=0x1234...",
//   supportedTokens: ["USDC", "ETH", "SOL"],
//   supportedChains: ["Ethereum", "Base", "Solana", "Polygon"]
// }

Returns both a CLI command and a web URL. Use the CLI for automation, or open the URL in a browser for a guided purchase flow.


CLI Integration

MoonPay CLI commands
# Check if MoonPay CLI is installed
mp --version

# Buy USDC for an agent wallet
mp buy --currency usdc --wallet 0x1234...

# List managed wallets
mp wallet list --json
Programmatic CLI usage
import { isMoonPayInstalled, getMoonPayWallets } from "@aegis-ows/integrations";

// Check CLI availability
if (isMoonPayInstalled()) {
  // List all wallets managed by MoonPay CLI
  const wallets = getMoonPayWallets();
  console.log("Managed wallets:", wallets);
  // ["0x1234...", "0x5678...", ...]
}

Web Widget

Generate a funding URL
const agentWallet = "0x1234...";
const fundingUrl = `https://www.moonpay.com/buy/usdc?walletAddress=${agentWallet}`;

// Open in browser for guided purchase flow
// MoonPay handles KYC, payment processing, and crypto delivery

No API key for URLs

The web widget URL works without authentication. MoonPay handles the full purchase flow including identity verification, payment processing, and delivery to the agent wallet.


Funding Flow

1

Agent Detects Low Balance

Budget policy alerts when agent balance drops below threshold.

2

Aegis Generates Funding URL

getMoonPayFundingOptions() returns a purchase URL for the agent wallet.

3

Operator Funds via Fiat

Credit card, debit card, or bank transfer through MoonPay checkout.

4

MoonPay Delivers Crypto

USDC, ETH, or SOL delivered directly to the agent wallet address.

5

Agent Resumes Operations

Agent detects new balance and resumes API purchases and service delivery.


Setup Guide

.env (all optional)
# Publishable key β€” enables embedded widget + currencies API
MOONPAY_API_KEY=pk_live_...

# Secret key β€” enables URL signing + transaction status queries
MOONPAY_SECRET_KEY=sk_live_...

# Webhook key β€” enables real-time transaction notifications
MOONPAY_WEBHOOK_KEY=whk_...

Graceful degradation

Everything works without API keys (external URLs). Each key unlocks more features. Same pattern as Zerion and Allium.

FeatureRequires
Buy/Sell/Swap URLsNothing (works out of the box)
Embedded widget (iframe)MOONPAY_SECRET_KEY
Currencies APIMOONPAY_API_KEY
Geo availability checkMOONPAY_API_KEY
Transaction statusMOONPAY_SECRET_KEY
WebhooksMOONPAY_WEBHOOK_KEY
CLI purchases@moonpay/cli

Hackathon Ideas

UX Track

Seamless fiat-to-agent funding flow β€” deploy and fund agents with a credit card

Onboarding

Zero-crypto-knowledge agent deployment β€” no MetaMask, no seed phrases for operators

Enterprise

Corporate card funding for agent fleets with expense tracking and receipts

Payments

Hybrid fiat/crypto agent economies β€” agents earn crypto, operators fund with fiat


API Reference

FunctionParametersReturns
getMoonPayBuyUrloptionsstring (signed URL)
getMoonPaySellUrloptionsstring (signed URL)
getMoonPaySwapUrloptionsstring
getMoonPayTransactionexternalIdMoonPayTransaction | null
getMoonPayCurrencies(none)MoonPayCurrency[]
checkMoonPayAvailabilityipAddress?MoonPayAvailability
validateMoonPayWebhookrawBody, signaturepayload | null
signMoonPayUrlurlstring | null
getMoonPayConfig(none)config object
getMoonPayFundingOptionswalletAddressFundingOption