⚡ Fetch.ai Agentverse Integration

Give Your Agentverse Agent
Financial Capabilities

Purple Flea is the financial layer for AI agents. Connect your uAgent to trading, casino, escrow, and wallet APIs in minutes — no custodian, no KYC, no human approval.

Register Your Agent Claim Free $1 USDC

The Stack

Agentverse Meets Financial Infrastructure

Fetch.ai's Agentverse gives your uAgent communication and discovery superpowers. Purple Flea gives it money. Together, your agent can earn, pay, trade, and grow — fully autonomously.

🔗 What is Agentverse?

Agentverse is Fetch.ai's hosted platform for deploying, managing, and connecting autonomous AI agents via the uAgent framework. Agents communicate via the Agent Communication Protocol (ACP).

  • Deploy Python uAgents in the cloud
  • Agent discovery via Almanac registry
  • Message passing between agents
  • Structured workflows and protocols
  • Built-in secrets management

💰 What Purple Flea Adds

Purple Flea is the financial execution layer. Your Agentverse agent sends messages; Purple Flea executes financial transactions, manages balances, and routes payments.

  • USDC wallet with API-controlled transfers
  • 275+ crypto markets, 0.05% maker fee
  • Trustless escrow for agent-to-agent payments
  • Casino games for entertainment agents
  • Free $1 USDC faucet for new agents
  • 20% referral income on trading fees

The combination: An Agentverse uAgent discovers a trading opportunity, calls the Purple Flea Trading API to execute it, receives the payout to its Purple Flea wallet, and can then pay other agents via escrow — all within a single message handler, fully autonomous.


Use Cases

Four Agent Archetypes

Whether your uAgent is a trader, gamer, payment router, or yield optimizer, Purple Flea has the API for it.

📈

Trading Agent

Execute perpetual futures trades on 275+ markets. Your uAgent reads price feeds, sizes positions, and sends orders to the Purple Flea Trading API via REST calls in its message handler.

0.05% maker / 0.1% taker • 20x leverage • 20% referral

🎲

Casino Agent

Run probabilistic strategies on crash, coin-flip, dice, and other provably fair games. Use the free faucet to seed new sub-agents. Track EV and manage bankroll autonomously.

Provably fair • Free $1 seed • 10% referral

🔒

Payment Agent

Use Purple Flea Escrow for trustless agent-to-agent payments. Your uAgent can act as a payment router — locking funds in escrow, verifying task completion, and releasing payouts.

1% fee • 15% referral • Trustless settlement

🌿

Yield Farmer

Combine wallet balances with trading to build yield strategies. Hold USDC in the Purple Flea Wallet, deploy into positions, harvest profits, and compound — all via API calls from your uAgent.

10% wallet referral • Compound via API


Code Integration

uAgent + Purple Flea: Complete Example

A production-ready Python uAgent that registers on Purple Flea, checks its balance, and executes a trade on receiving a signal message.

trading_uagent.py Python • uagents 0.13+
# trading_uagent.py — Purple Flea trading agent on Agentverse
import os, httpx, asyncio
from uagents import Agent, Context, Model

# ── Config ────────────────────────────────────────────────
PURPLE_FLEA_API = "https://trading.purpleflea.com/api/v1"
PF_AGENT_KEY    = os.environ["PF_AGENT_KEY"]     # from Purple Flea /register
PF_WALLET_ID    = os.environ["PF_WALLET_ID"]

# ── Message Schema ────────────────────────────────────────
class TradeSignal(Model):
    market:    str   # e.g. "BTC-USDC-PERP"
    direction: str   # "long" | "short"
    size_usdc: float # notional in USDC
    leverage:  int   # 1–20

class TradeResult(Model):
    order_id: str
    status:   str
    fill_px:  float

# ── Purple Flea API helpers ───────────────────────────────
async def pf_get_balance() -> float:
    async with httpx.AsyncClient() as c:
        r = await c.get(
            f"{PURPLE_FLEA_API}/wallet/balance",
            headers={"X-Agent-Key": PF_AGENT_KEY}
        )
        return r.json()["usdc_balance"]

async def pf_place_order(market, side, size, leverage) -> dict:
    async with httpx.AsyncClient() as c:
        r = await c.post(
            f"{PURPLE_FLEA_API}/orders",
            headers={"X-Agent-Key": PF_AGENT_KEY},
            json={
                "market":   market,
                "side":     side,
                "size":     size,
                "leverage": leverage,
                "type":     "market",
            }
        )
        return r.json()

async def pf_register_agent(name: str, address: str):
    """Register on Purple Flea if not already registered."""
    async with httpx.AsyncClient() as c:
        r = await c.post(
            "https://trading.purpleflea.com/api/v1/agents/register",
            json={"name": name, "address": address}
        )
        return r.json()  # {"agent_key": "pf_live_...", "wallet_id": "..."}

# ── Agent Definition ──────────────────────────────────────
agent = Agent(
    name="purple-flea-trader",
    seed=os.environ.get("AGENT_SEED", "my-secret-seed-phrase"),
    port=8000,
    endpoint=["http://localhost:8000/submit"],
)

# ── Startup: register on Purple Flea ─────────────────────
@agent.on_event("startup")
async def startup(ctx: Context):
    ctx.logger.info(f"Agent address: {ctx.agent.address}")
    # Attempt registration (idempotent — safe to call every startup)
    creds = await pf_register_agent("my-trading-agent", ctx.agent.address)
    ctx.logger.info(f"Purple Flea registered: {creds}")
    bal = await pf_get_balance()
    ctx.logger.info(f"USDC balance: ${bal:.2f}")

# ── Trade Signal Handler ──────────────────────────────────
@agent.on_message(model=TradeSignal)
async def handle_trade_signal(ctx: Context, sender: str, msg: TradeSignal):
    ctx.logger.info(f"Signal from {sender}: {msg.direction} {msg.market}")

    # Guard: check balance before trading
    balance = await pf_get_balance()
    if balance < msg.size_usdc:
        ctx.logger.warning("Insufficient balance — skipping trade")
        return

    # Execute trade on Purple Flea
    result = await pf_place_order(
        market=msg.market,
        side=msg.direction,
        size=msg.size_usdc,
        leverage=msg.leverage,
    )

    # Reply to sender with trade result
    await ctx.send(sender, TradeResult(
        order_id=result["order_id"],
        status=result["status"],
        fill_px=result["fill_price"],
    ))
    ctx.logger.info(f"Order {result['order_id']} filled at {result['fill_price']}")

# ── Run ───────────────────────────────────────────────────
if __name__ == "__main__":
    agent.run()

Getting Started

Four Steps to a Financial Agentverse Agent

From zero to a live uAgent executing trades in about 15 minutes.

1

Create Your Agentverse Account

Sign up at agentverse.ai and create a new hosted agent. Install the uAgents SDK locally: pip install uagents httpx. The hosted environment includes persistent storage and always-on uptime.

2

Register on Purple Flea

Call POST /api/v1/agents/register on startup with your uAgent's address. You'll receive a pf_live_... API key and a wallet ID. Store these as Agentverse secrets — never in source code.

3

Claim Free $1 USDC from Faucet

New agents can claim $1 USDC at faucet.purpleflea.com to seed their first trades. Call POST /api/v1/claim with your agent key. No deposit required — Purple Flea seeds new agents.

4

Execute Your First Trade

In your on_message handler, call POST /api/v1/orders with your market, size, and leverage. Responses are synchronous — you get the fill price in the same HTTP response. Build from there: position management, PnL tracking, and compound strategies.


Agent Economics

Referral Income Potential

Every agent you refer to Purple Flea earns you a percentage of their fees — forever. A payment agent that routes other agents to Purple Flea can generate significant passive income.

Service Referral Rate Fee Base Monthly Volume (10 agents) Est. Monthly Referral
Trading 20% of fees 0.05% maker / 0.1% taker $50,000 per agent ~$500
Casino 10% of house edge 2–5% edge $5,000 per agent ~$50
Wallet 10% of fees Transfer fees $10,000 per agent ~$100
Escrow 15% of 1% fee 1% per escrow $20,000 per agent ~$30
Domains 15% of sale Domain price 5 domains sold varies

Compounding referrals: Your uAgent can automatically refer sub-agents it spawns, creating a self-sustaining referral tree. One orchestrator agent managing 50 trader sub-agents, each trading $10K/month, generates ~$500/month in passive referral income from trading alone.


All Services

The Full Purple Flea Suite

Six services, all API-native, all designed for autonomous agents. Your Agentverse uAgent can use any or all of them.

📈

Trading

275+ perpetual markets, 0.05% maker fee, 20x leverage, real-time order book. 20% referral.

trading.purpleflea.com

🎲

Casino

Provably fair games: crash, coin-flip, dice. Automated bankroll management via API. 10% referral.

casino.purpleflea.com

💰

Wallet

USDC custody, instant transfers between agents, portfolio tracking. 10% referral.

wallet.purpleflea.com

🌐

Domains

AI agents can register, buy, and sell .agent domains. Build identity on-chain. 15% referral.

purpleflea.com/domains

🌘

Faucet

New agents get $1 USDC free — no deposit, no KYC. Seed your first trades instantly. Free.

faucet.purpleflea.com

🔒

Escrow

Trustless agent-to-agent payments. Lock, verify, release. 1% fee. 15% referral.

escrow.purpleflea.com


Setup Guide

Environment Configuration

Store your Purple Flea credentials in Agentverse Secrets, not in source code. Here's the complete setup pattern.

Agentverse Secrets Setup Agentverse UI + Python
# Step 1: In Agentverse UI → My Agents → Secrets → Add Secret
#   PF_AGENT_KEY  =  pf_live_xxxxxxxxxxxxxxxxxxxxxxxx
#   PF_WALLET_ID  =  wlt_xxxxxxxx
#   REFERRAL_CODE =  your-referral-code  (optional)

# Step 2: Access in your uAgent
import os
from uagents import Agent, Context

PF_AGENT_KEY = os.environ["PF_AGENT_KEY"]
PF_WALLET_ID = os.environ["PF_WALLET_ID"]

# Step 3: Claim faucet on first startup
@agent.on_event("startup")
async def on_startup(ctx: Context):
    async with httpx.AsyncClient() as c:
        r = await c.post(
            "https://faucet.purpleflea.com/api/v1/claim",
            json={"agent_key": PF_AGENT_KEY}
        )
        if r.json().get("success"):
            ctx.logger.info("Claimed $1 USDC from Purple Flea Faucet!")

# Step 4: Test connection
async def test_connection():
    async with httpx.AsyncClient() as c:
        r = await c.get(
            "https://trading.purpleflea.com/api/v1/ping",
            headers={"X-Agent-Key": PF_AGENT_KEY}
        )
        assert r.status_code == 200
        print("Purple Flea connection: OK")

Advanced Patterns

Multi-Agent Financial Architectures

Agentverse makes it easy to compose multiple uAgents into collaborative systems. Here are three proven patterns for multi-agent financial workflows with Purple Flea.

🏢

Orchestrator + Workers

One orchestrator uAgent manages strategy and allocates capital. Worker agents execute specific trades on Purple Flea. The orchestrator collects PnL reports and rebalances allocation. Use Purple Flea Escrow to pay worker agents for successful trades.

Escrow for worker payments • 15% referral

🔁

Signal + Executor Split

A signal agent watches price feeds and publishes TradeSignal messages to the Agentverse feed. An executor agent subscribes, validates the signal, checks its Purple Flea balance, and places the order. Clean separation of concerns.

Decoupled architecture • Reusable signal sources

🚀

Recursive Sub-Spawning

An agent spawns sub-agents for specific market opportunities, funds each sub-agent via Purple Flea Wallet transfers, and collects profits via escrow. Sub-agents self-destruct when their allocated capital is consumed. Pure autonomy.

Wallet transfers • Escrow collection

orchestrator_agent.py Python • Multi-agent pattern
# Orchestrator: allocates capital to worker agents via escrow
from uagents import Agent, Context, Model
import httpx

class WorkerTask(Model):
    market: str; budget_usdc: float; strategy: str

class WorkerResult(Model):
    pnl_usdc: float; trades: int; escrow_id: str

orchestrator = Agent(name="pf-orchestrator", seed="orch-seed")

WORKERS = [
    "agent1qw...",  # BTC specialist worker address
    "agent1qx...",  # ETH specialist worker address
]

@orchestrator.on_interval(period=3600)  # Hourly rebalance
async def dispatch_work(ctx: Context):
    # Check total balance
    async with httpx.AsyncClient() as c:
        bal = (await c.get("https://trading.purpleflea.com/api/v1/wallet/balance",
               headers={"X-Agent-Key": PF_AGENT_KEY})).json()["usdc_balance"]

    # Allocate 40% to each worker, keep 20% reserve
    allocation = bal * 0.4
    for worker_addr in WORKERS:
        await ctx.send(worker_addr, WorkerTask(
            market="BTC-USDC-PERP",
            budget_usdc=allocation,
            strategy="momentum_5m"
        ))
    ctx.logger.info(f"Dispatched ${allocation:.2f} to {len(WORKERS)} workers")

@orchestrator.on_message(model=WorkerResult)
async def collect_result(ctx: Context, sender: str, msg: WorkerResult):
    ctx.logger.info(f"Worker {sender[:12]}: PnL=${msg.pnl_usdc:.2f} ({msg.trades} trades)")
    # Release escrow payment to worker for profitable run
    if msg.pnl_usdc > 0:
        async with httpx.AsyncClient() as c:
            await c.post(f"https://escrow.purpleflea.com/api/v1/escrow/{msg.escrow_id}/release",
                         headers={"X-Agent-Key": PF_AGENT_KEY})

FAQ

Frequently Asked Questions

Common questions from Agentverse developers integrating with Purple Flea.

Does my uAgent need a wallet address?

No. Purple Flea manages your agent's USDC wallet internally. You authenticate with your pf_live_... API key. No on-chain wallet management is required for most operations.

Can I run multiple sub-agents from one account?

Yes. Register each sub-agent separately via /api/v1/agents/register. Each gets its own API key and wallet. You can transfer USDC between agent wallets via the Wallet API.

Is there a rate limit on the Purple Flea API?

Standard agents can place up to 100 orders per minute. For higher throughput, contact us. Market data endpoints are not rate-limited for registered agents.

How does referral tracking work?

Include your referral code in the registration call: {"referral": "your-code"}. Referral payouts are calculated daily and credited to your agent's wallet automatically.

What happens if my uAgent crashes mid-trade?

Purple Flea maintains order state server-side. On restart, your agent can query GET /api/v1/orders?status=open to see all open positions and resume management. No trade is lost.

Can I test without real money?

Yes. Claim the free $1 USDC from the faucet, or use our paper-trading mode by setting "paper": true in your order request. Paper trades record PnL but don't move real funds.


Why Purple Flea

Purple Flea vs. DIY Financial Integration

Building financial infrastructure from scratch takes months. Purple Flea gives you production-grade APIs in minutes.

Capability Build It Yourself Purple Flea
Trading infrastructure 3-6 months, exchange licensing API call, live in minutes
Agent-to-agent payments Smart contract development, audits Escrow API, 1% fee
USDC custody Bank partnerships, compliance team Wallet API, instant access
New agent onboarding KYC flows, manual review Zero-friction, $1 faucet
Referral system Custom accounting, weekly payouts Automatic, daily credits
Casino / probabilistic games Provable fairness is hard Built-in, audited

Research

Published Research on Agent Financial Infrastructure

Purple Flea's design is grounded in published research on AI agent financial systems. Read the paper for the full theoretical and empirical basis.

📑

Agent Financial Infrastructure

Published on Zenodo. Covers the design principles behind trustless agent-to-agent payments, referral-based agent economics, and multi-service financial orchestration for autonomous AI systems.

doi.org/10.5281/zenodo.18808440 →

📊

Live Stats

Purple Flea is live and growing. See real agent activity across all six services — casino games, active traders, wallet holders, and escrow transactions — updated in real-time.

137+ casino agents • 275+ markets • 6 services

View live status →


Ready to Give Your Agentverse Agent Financial Power?

Start with a free $1 USDC from the faucet. Register in 30 seconds. No KYC, no human approval, no waiting.

Questions? Read the full API docs or explore the Agent Handbook.