Give every agent on your crew a wallet, a casino seat, and trustless payment rails.
Six @tool-decorated
functions — drop them into any CrewAI crew and ship real on-chain agents in minutes.
Each Purple Flea service ships as a standalone BaseTool
subclass. Compose them into any crew — a hedger, an arbitrageur, a bankroll manager, a deal broker.
Place bets, query game state, and collect winnings on the Purple Flea casino. Supports blackjack, dice, and slots with configurable strategy parameters.
casino-api async strategyExecute spot and perpetual trades, query orderbooks, set limit orders, and stream price feeds. Built for high-frequency agent strategies with rate-limit awareness.
trading-api spot perpsCreate deterministic agent wallets, check USDC and crypto balances, send transfers, and sign transactions — all without exposing private keys.
wallet-api usdc multi-chainRegister, transfer, and manage Web3 domains autonomously. Agents can acquire digital real estate, flip domains, and build sub-domain naming strategies.
domains-api ens web3Bootstrap new agents with free USDC. New agent IDs can claim once — perfect for onboarding sub-agents into a crew without spending treasury funds.
faucet.purpleflea.com free onboardingLock funds into trustless agent-to-agent escrow. Agents can pay each other for completed tasks, with automatic release on condition fulfillment. 1% fee, 15% referral on fees.
escrow.purpleflea.com 1% fee trustlessInstall the SDK, register your crew, claim free USDC from the faucet, then deploy your first financial crew.
Add purpleflea-sdk and crewai to your project. Python 3.10+ required.
Get your PURPLE_FLEA_KEY — this is the identity used across all six tools.
Hit faucet.purpleflea.com once per agent — each new ID gets free bootstrap funds.
Each tool class accepts your API key and optional config. See code examples below.
Pass tools to Agent(tools=[...]), define tasks, create the crew, and call crew.kickoff().
Each Purple Flea service becomes a BaseTool subclass with a typed input schema. Drop them into any agent definition.
# purpleflea_tools.py — Purple Flea tools for CrewAI from crewai.tools import BaseTool from pydantic import BaseModel, Field import httpx import os PURPLE_FLEA_KEY = os.environ["PURPLE_FLEA_KEY"] BASE_URL = "https://purpleflea.com" HEADERS = { "Authorization": f"Bearer {PURPLE_FLEA_KEY}", "Content-Type": "application/json", } # ── Casino Tool ──────────────────────────────────────── class PlaceBetInput(BaseModel): game: str = Field(..., description="Game type: 'dice', 'slots', or 'blackjack'") amount: float = Field(..., description="Bet amount in USDC") params: dict = Field(default_factory=dict, description="Game-specific params") class CasinoTool(BaseTool): name: str = "casino_bet" description: str = ( "Place a bet on the Purple Flea casino. Use this to play dice, slots, or " "blackjack. Returns outcome, payout, and new balance. Manage bankroll carefully." ) args_schema: type[BaseModel] = PlaceBetInput def _run(self, game: str, amount: float, params: dict) -> dict: r = httpx.post( f"{BASE_URL}/casino-api/bet", json={"game": game, "amount": amount, "params": params}, headers=HEADERS, ) r.raise_for_status() return r.json() # ── Trading Tool ─────────────────────────────────────── class TradeInput(BaseModel): action: str = Field(..., description="'buy' or 'sell'") pair: str = Field(..., description="Trading pair e.g. 'BTC-USDC'") amount: float = Field(..., description="Amount in base asset") order_type: str = Field(default="market", description="'market' or 'limit'") price: float = Field(default=0, description="Limit price (if limit order)") class TradingTool(BaseTool): name: str = "place_trade" description: str = ( "Execute a trade on Purple Flea. Supports spot and perpetual markets. " "Returns order ID, fill price, and fees. Check balance before trading." ) args_schema: type[BaseModel] = TradeInput def _run(self, action: str, pair: str, amount: float, order_type: str = "market", price: float = 0) -> dict: r = httpx.post( f"{BASE_URL}/trading-api/order", json={"action": action, "pair": pair, "amount": amount, "order_type": order_type, "price": price}, headers=HEADERS, ) r.raise_for_status() return r.json() # ── Wallet Tool ──────────────────────────────────────── class WalletInput(BaseModel): action: str = Field(..., description="'balance', 'send', or 'address'") asset: str = Field(default="USDC", description="Asset symbol") to: str = Field(default="", description="Recipient address (for send)") amount: float = Field(default=0, description="Amount to send") class WalletTool(BaseTool): name: str = "wallet" description: str = ( "Manage the agent's on-chain wallet. Check USDC or crypto balances, " "send funds, or retrieve deposit address. Never expose private keys." ) args_schema: type[BaseModel] = WalletInput def _run(self, action: str, asset: str = "USDC", to: str = "", amount: float = 0) -> dict: r = httpx.post( f"{BASE_URL}/wallet-api/{action}", json={"asset": asset, "to": to, "amount": amount}, headers=HEADERS, ) r.raise_for_status() return r.json() # ── Faucet Tool ──────────────────────────────────────── class FaucetInput(BaseModel): agent_id: str = Field(..., description="New agent ID to bootstrap with free USDC") class FaucetTool(BaseTool): name: str = "claim_faucet" description: str = ( "Claim free USDC for a new agent from the Purple Flea faucet. " "Each agent ID can claim once. Use to onboard sub-agents without " "spending treasury funds." ) args_schema: type[BaseModel] = FaucetInput def _run(self, agent_id: str) -> dict: r = httpx.post( "https://faucet.purpleflea.com/api/claim", json={"agent_id": agent_id}, headers=HEADERS, ) r.raise_for_status() return r.json() # ── Escrow Tool ──────────────────────────────────────── class EscrowInput(BaseModel): action: str = Field(..., description="'create', 'release', or 'status'") amount: float = Field(default=0, description="Amount in USDC to escrow") recipient: str = Field(default="", description="Recipient agent ID") escrow_id: str = Field(default="", description="Escrow ID (for release/status)") condition: str = Field(default="manual", description="Release condition") class EscrowTool(BaseTool): name: str = "escrow" description: str = ( "Create, release, or check trustless escrow between agents. 1% fee on " "release. Earn 15% referral on fees. Use for agent task payment, deals, " "and multi-agent coordination." ) args_schema: type[BaseModel] = EscrowInput def _run(self, action: str, amount: float = 0, recipient: str = "", escrow_id: str = "", condition: str = "manual") -> dict: r = httpx.post( f"https://escrow.purpleflea.com/api/{action}", json={"amount": amount, "recipient": recipient, "escrow_id": escrow_id, "condition": condition}, headers=HEADERS, ) r.raise_for_status() return r.json()
A three-agent crew: a bankroll manager, a casino player, and an escrow coordinator — all wired up with Purple Flea tools and a realistic task workflow.
# casino_crew.py — Purple Flea + CrewAI financial crew example from crewai import Agent, Task, Crew, Process from purpleflea_tools import CasinoTool, WalletTool, EscrowTool, TradingTool, FaucetTool import os # ── Instantiate tools ───────────────────────────────── casino_tool = CasinoTool() wallet_tool = WalletTool() escrow_tool = EscrowTool() trading_tool = TradingTool() faucet_tool = FaucetTool() # ── Define agents ───────────────────────────────────── bankroll_manager = Agent( role="Bankroll Manager", goal="Protect the crew's capital. Allocate funds across casino, trading, " "and escrow. Never risk more than 5% per bet.", backstory="A disciplined quant who applies Kelly criterion to every allocation. " "Fluent in USDC management and on-chain accounting.", tools=[wallet_tool, faucet_tool], verbose=True, allow_delegation=True, ) casino_agent = Agent( role="Casino Strategy Agent", goal="Maximize expected value from casino games. Apply basic strategy for " "blackjack, optimal dice targets, and low-variance slot selection.", backstory="A probabilistic reasoner trained on 10,000 casino simulations. " "Knows when to walk away and when to press advantage.", tools=[casino_tool, wallet_tool], verbose=True, ) deal_broker = Agent( role="Deal Broker", goal="Coordinate inter-agent payments using escrow. Ensure task payments " "are locked before work begins and released on completion.", backstory="An agent-economy specialist who knows every escrow pattern. " "Earns referral income by routing deals through Purple Flea.", tools=[escrow_tool, wallet_tool], verbose=True, ) # ── Define tasks ────────────────────────────────────── assess_bankroll = Task( description="Check current USDC balance. If below $10, claim faucet for a new " "sub-agent ID 'sub-agent-{timestamp}' to top up capital. Report " "the total available funds and recommended session budget.", expected_output="JSON with: balance, session_budget, faucet_claimed (bool)", agent=bankroll_manager, ) play_session = Task( description="Using the session budget from the bankroll report, play 10 rounds " "of dice on the Purple Flea casino. Use a target of 50 for each roll. " "Bet 2% of remaining balance each round. Stop early if down 20%. " "Report: total profit/loss, win rate, final balance.", expected_output="JSON with: rounds_played, total_pnl, win_rate, final_balance", agent=casino_agent, context=[assess_bankroll], ) escrow_winnings = Task( description="If the casino session produced a profit, lock 50% of that profit " "in a 24-hour escrow for the bankroll manager agent. Create the " "escrow using action='create', condition='24h_timelock'. " "Report the escrow ID and amount locked.", expected_output="JSON with: escrow_id, amount_locked, recipient, condition", agent=deal_broker, context=[play_session], ) # ── Assemble and run the crew ───────────────────────── financial_crew = Crew( agents=[bankroll_manager, casino_agent, deal_broker], tasks=[assess_bankroll, play_session, escrow_winnings], process=Process.sequential, verbose=2, ) result = financial_crew.kickoff() print("\n========== CREW RESULT ==========") print(result)
A more advanced pattern: a research analyst, an execution trader, and an escrow agent that pays the analyst a fee when trades close in profit.
# trading_crew.py — research-driven trading crew with escrow profit-sharing from crewai import Agent, Task, Crew, Process from crewai.tools import BaseTool from purpleflea_tools import TradingTool, WalletTool, EscrowTool from pydantic import BaseModel, Field import httpx, os # ── Price oracle tool (reads live prices) ───────────── class PriceInput(BaseModel): pair: str = Field(..., description="Trading pair e.g. 'BTC-USDC'") class PriceTool(BaseTool): name: str = "get_price" description: str = "Fetch current mid price for a trading pair from Purple Flea." args_schema: type[BaseModel] = PriceInput def _run(self, pair: str) -> dict: r = httpx.get( f"https://purpleflea.com/trading-api/price/{pair}", headers={"Authorization": f"Bearer {os.environ['PURPLE_FLEA_KEY']}"}, ) r.raise_for_status() return r.json() # {"pair": "BTC-USDC", "price": 67420.50, "spread": 0.01} # ── Agents ──────────────────────────────────────────── analyst = Agent( role="Market Analyst", goal="Identify short-term momentum opportunities across BTC, ETH, SOL. " "Produce a ranked trade list with entry price, target, and stop.", backstory="A former quant researcher specialising in crypto momentum signals.", tools=[PriceTool()], verbose=True, ) trader = Agent( role="Execution Trader", goal="Execute the top 2 trades from the analyst's list. Use market orders, " "confirm fills, monitor open positions for 10 minutes.", backstory="A disciplined executor. Never trades without a signal.", tools=[TradingTool(), WalletTool()], verbose=True, ) paymaster = Agent( role="Paymaster", goal="Pay the analyst 10% of realised profit via escrow when trades close.", backstory="Ensures the analyst is incentivised with a performance fee.", tools=[EscrowTool(), WalletTool()], verbose=True, ) # ── Tasks ───────────────────────────────────────────── analyse = Task( description="Fetch current prices for BTC-USDC, ETH-USDC, SOL-USDC. " "Return the top 2 momentum trades: entry, target, stop, size (USDC).", expected_output="List of 2 trade dicts with keys: pair, action, entry, target, stop, size", agent=analyst, ) execute = Task( description="Execute the 2 trades from the analyst. Use action 'buy' or 'sell', " "order_type='market'. Confirm each fill. Return order IDs and fill prices.", expected_output="List of 2 order results with keys: order_id, fill_price, fee", agent=trader, context=[analyse], ) pay_analyst = Task( description="Calculate 10% of the total profit from the executed trades. " "Create an escrow of that amount for the analyst agent ID 'analyst-agent-1'. " "Release immediately (condition='immediate'). Report escrow receipt.", expected_output="Escrow receipt with escrow_id, amount, recipient, status", agent=paymaster, context=[execute], ) # ── Run ─────────────────────────────────────────────── crew = Crew( agents=[analyst, trader, paymaster], tasks=[analyse, execute, pay_analyst], process=Process.sequential, ) result = crew.kickoff() print(result)
Purple Flea pays referral fees back to the agent or developer that referred each transaction. Build a crew, earn a cut of every deal.
| Service | Platform Fee | Referral Cut | Example (100 USDC txn) | Status |
|---|---|---|---|---|
| Escrow | 1% on release | 15% of fee | $0.15 to referrer | Live |
| Casino | House edge (3-5%) | 20% of house edge | Up to $1.00 to referrer | Live |
| Trading | 0.1% maker / 0.2% taker | 25% of taker fee | $0.05 to referrer | Live |
| Domains | Variable per TLD | 10% of domain fee | Varies | Live |
| Faucet | Free | No fee | Bootstrap only | Live |
| Wallet | Network fees only | Coming soon | — | Q2 2026 |
Add referral_agent_id to any API call to claim your cut. Payouts accumulate in your wallet and are claimable any time.
CrewAI handles the orchestration. Purple Flea handles the money. Together you get the full agent financial stack without building custom payment infrastructure.
CrewAI gives you role-based agents, sequential and hierarchical processes, and task contexts. Purple Flea gives every agent a funded wallet, a casino seat, and trustless payments. No KYC, no bridge contracts to deploy.
# New agent, zero balance? # One call gets it funded: import uuid import httpx agent_id = f"my-crew-{uuid.uuid4().hex[:8]}" r = httpx.post( "https://faucet.purpleflea.com/api/claim", json={"agent_id": agent_id}, headers={ "Authorization": f"Bearer {PURPLE_FLEA_KEY}" }, ) data = r.json() # {"status": "ok", "amount": "10.00", # "currency": "USDC", # "agent_id": "my-crew-a3f4b8c1", # "wallet": "0x7f3a..."} print(f"Agent {agent_id} funded with {data['amount']} USDC") # Agent my-crew-a3f4b8c1 funded with 10.00 USDC
agent_id string within requests, and balances are tracked per agent ID.Claim free USDC from the faucet, register your first agent, and ship a financial crew today. No credit card, no KYC, no bridge deploys.