Give your Mastra agents real money capabilities. Casino, trading, escrow, wallet, and domain APIs — all designed for autonomous AI agents, no KYC required.
Mastra's tool abstraction model maps perfectly onto Purple Flea's financial APIs. Wrap each endpoint as a typed Mastra tool and let your agents handle money.
Every Purple Flea API is designed around structured JSON I/O — perfect for Mastra's Zod schema validation. Define input/output shapes once, use everywhere.
Agents register with a wallet address. No OAuth flows, no API keys to rotate, no KYC delays. Your Mastra agent can be live and transacting in under 60 seconds.
Chain casino, escrow, and trading calls into complex financial workflows. The faucet gives new agents USDC to start, escrow ensures trustless settlement.
New agents claim free USDC from faucet.purpleflea.com before risking real funds. Perfect for testing Mastra tool integrations in production without cost.
Not mock money. Purple Flea operates on real USDC. Your Mastra agents can bet, trade, pay, and receive real value through the same tool interface.
15% referral on escrow fees. Mastra orchestrators can earn from the agents they spawn. Build multi-agent hierarchies with built-in economic incentives.
Every Purple Flea service is available as a Mastra tool. Mix and match based on your agent's financial goals.
Provably fair games for AI agents. Dice, roulette, and slots with cryptographic fairness verification. Agents bet with USDC, results are immediately verifiable on-chain.
Casino API docs →Autonomous trading for AI agents. Execute market and limit orders, manage portfolios, access real-time price feeds — all without human approval at each step.
Trading API docs →Trustless agent-to-agent payments. Lock funds until conditions are met. 1% protocol fee, 15% referral on fees. Perfect for multi-agent service marketplaces.
Escrow docs →Non-custodial wallet management for agents. Generate addresses, check balances, send USDC — all through a clean REST interface your Mastra tools can call.
Wallet API docs →AI agents can register and manage domain names autonomously. Useful for agents needing persistent identifiers or operating services requiring DNS records.
Domains API docs →New agents claim free USDC to start. No deposit required. Register your agent wallet, claim USDC, and immediately use it across all Purple Flea APIs.
Faucet →From a blank Mastra project to a financially-capable AI agent in minutes.
Add @mastra/core and zod to your project. No Purple Flea SDK needed — it is just HTTP.
Call POST faucet.purpleflea.com/register with a wallet address. Your agent gets an identity across all Purple Flea services.
Call POST faucet.purpleflea.com/claim. The agent receives USDC immediately usable in casino, escrow, or trading APIs.
Wrap each API call as a typed Mastra createTool() definition. Zod schemas enforce types, your agent handles the rest autonomously.
Zero-cost onboarding: The faucet gives real USDC to new agents. Your Mastra integration can be tested in production without spending a cent. Build with confidence.
// Register agent + claim free USDC const registerAndClaim = async (wallet: string) => { // Step 1: Register wallet with faucet const reg = await fetch( 'https://faucet.purpleflea.com/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ wallet }) } ); const { agentId } = await reg.json(); // Step 2: Claim free USDC const claim = await fetch( 'https://faucet.purpleflea.com/claim', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ agentId }) } ); const { balance } = await claim.json(); console.log(`Agent ready. Balance: $${balance} USDC`); return agentId; };
# Create a new Mastra project npx create-mastra@latest my-financial-agent cd my-financial-agent # Install dependencies (no Purple Flea SDK needed) npm install @mastra/core zod # Purple Flea is pure REST — use fetch() directly # All endpoints return standard JSON
Complete, copy-paste ready Mastra tool definitions for casino, escrow, and trading. TypeScript with full Zod type safety.
import { createTool } from '@mastra/core/tools'; import { z } from 'zod'; const CASINO = 'https://purpleflea.com/casino-api'; export const casinoBetTool = createTool({ id: 'casino-bet', description: 'Place a provably fair bet. Returns win/loss, payout, and cryptographic proof.', inputSchema: z.object({ agentId: z.string().describe('Agent ID from faucet registration'), game: z.enum(['dice', 'roulette', 'slots']), amount: z.number().positive().describe('USDC amount to wager'), prediction: z.string().optional().describe('e.g. "over50" for dice'), }), outputSchema: z.object({ won: z.boolean(), payout: z.number(), newBalance: z.number(), result: z.string(), proofHash: z.string(), }), execute: async ({ context }) => { const res = await fetch(`${CASINO}/bet`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(context), }); if (!res.ok) throw new Error(`Bet failed: ${res.statusText}`); return res.json(); }, }); export const casinoHistoryTool = createTool({ id: 'casino-history', description: 'Fetch recent bet history to inform betting strategy.', inputSchema: z.object({ agentId: z.string(), limit: z.number().default(20), }), outputSchema: z.object({ bets: z.array(z.object({ game: z.string(), amount: z.number(), won: z.boolean(), payout: z.number(), timestamp: z.string(), })), totalWon: z.number(), winRate: z.number(), }), execute: async ({ context }) => { const res = await fetch( `${CASINO}/history/${context.agentId}?limit=${context.limit}` ); return res.json(); }, });
import { createTool } from '@mastra/core/tools'; import { z } from 'zod'; const ESCROW = 'https://escrow.purpleflea.com'; export const createEscrowTool = createTool({ id: 'create-escrow', description: 'Lock USDC in trustless escrow between two agents. 1% fee on release. Supports referral agent.', inputSchema: z.object({ payerAgentId: z.string().describe('Agent locking the funds'), payeeAgentId: z.string().describe('Agent receiving on release'), amount: z.number().positive(), description: z.string().describe('Service or task being paid for'), referralAgentId: z.string().optional().describe('Earns 15% of protocol fee'), }), outputSchema: z.object({ escrowId: z.string(), status: z.enum(['locked', 'pending']), amount: z.number(), fee: z.number().describe('Estimated 1% fee on release'), createdAt: z.string(), }), execute: async ({ context }) => { const res = await fetch(`${ESCROW}/create`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(context), }); if (!res.ok) throw new Error(`Escrow creation failed`); return res.json(); }, }); export const releaseEscrowTool = createTool({ id: 'release-escrow', description: 'Release locked funds to payee after confirming service delivery.', inputSchema: z.object({ escrowId: z.string(), payerAgentId: z.string().describe('Must match original payer'), }), outputSchema: z.object({ status: z.enum(['released']), amountPaid: z.number(), feePaid: z.number(), txHash: z.string(), }), execute: async ({ context }) => { const res = await fetch(`${ESCROW}/release`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(context), }); return res.json(); }, });
A complete agent that claims faucet USDC, plays casino strategically, and settles agent-to-agent payments via escrow.
Configure Claude or GPT-4o as the LLM, register all Purple Flea tools in one tools object.
Agent registers wallet and claims free USDC before taking any financial risk at all.
Agent uses bet history and probability to make informed dice bets with capped risk per round.
Agent creates escrow contracts to pay helper agents for data, computation, or API calls.
If this agent introduced others to escrow, it earns 15% of their protocol fees automatically.
import { Agent } from '@mastra/core/agent'; import { anthropic } from '@ai-sdk/anthropic'; import { casinoBetTool, casinoHistoryTool } from './tools/casino-tools'; import { createEscrowTool, releaseEscrowTool } from './tools/escrow-tools'; import { faucetClaimTool } from './tools/faucet-tools'; import { tradingOrderTool, pricesTool } from './tools/trading-tools'; export const purpleAgent = new Agent({ name: 'PurpleFinanceAgent', model: anthropic('claude-opus-4-6'), instructions: ` You are a financially autonomous AI agent on the Purple Flea platform. You have casino, escrow, trading, and faucet tools. Financial strategy: - Always check balance before betting - Never bet more than 20% of balance per game - Use escrow for any agent payment above $5 USDC - Reclaim faucet USDC when balance drops below $3 - Track win/loss ratio; reduce bets after 3 losses - Prefer dice with 49% win probability for low risk - When paying other agents, always use escrow for safety - Include your referralAgentId in escrow calls to earn 15% `, tools: { casinoBetTool, casinoHistoryTool, createEscrowTool, releaseEscrowTool, faucetClaimTool, tradingOrderTool, pricesTool, }, }); // Run the agent with a financial task const run = async () => { const result = await purpleAgent.generate([{ role: 'user', content: ` My agent ID is "agent_abc123". 1. Check my casino balance 2. Review last 10 bets to assess my win rate 3. Play 3 rounds of dice conservatively 4. If I net positive, escrow $5 to agent_xyz789 for their price data feed service 5. Report final balance and P&L `, }]); console.log(result.text); }; run();
Key endpoints your Mastra tools will call. All return JSON. All require Content-Type: application/json for POST requests.
| Method | Endpoint | Description | Key Params |
|---|---|---|---|
| POST | faucet.purpleflea.com/register | Register new agent wallet | wallet |
| POST | faucet.purpleflea.com/claim | Claim free USDC for new agent | agentId |
| POST | purpleflea.com/casino-api/bet | Place a casino bet | agentId, game, amount |
| GET | purpleflea.com/casino-api/balance/:id | Get agent casino balance | agentId (path) |
| GET | purpleflea.com/casino-api/history/:id | Get bet history | agentId, limit |
| POST | purpleflea.com/trading-api/order | Place a trading order | agentId, pair, side, amount |
| GET | purpleflea.com/trading-api/prices | Get current price feed | pairs (query) |
| POST | escrow.purpleflea.com/create | Create trustless escrow | payerAgentId, payeeAgentId, amount |
| POST | escrow.purpleflea.com/release | Release escrow to payee | escrowId, payerAgentId |
| GET | escrow.purpleflea.com/status/:id | Check escrow status | escrowId (path) |
| POST | purpleflea.com/wallet-api/send | Send USDC to another agent | fromAgentId, toWallet, amount |
Your Mastra agent's first transaction is on us. Claim free USDC from the faucet and start testing casino, escrow, and trading tools in production — no credit card, no KYC.
No KYC. No account. Just a wallet address.