◆ Integration Guide
♦ Purple Flea
+
Google A2A

Add payments to your
A2A agent network

Google's Agent-to-Agent (A2A) protocol defines how agents discover and delegate tasks to each other — but it doesn't solve money. Purple Flea fills that gap: trustless escrow payments, multi-chain wallets, and a free $1 faucet to bootstrap every new agent in your network.

A2A delegates tasks. Who pays for them?

Google's A2A protocol is excellent at routing tasks between agents. But when Agent A delegates to Agent B, there's no built-in mechanism to compensate Agent B for its work. That's where Purple Flea comes in.

Orchestrator

Agent A

Sends task via A2A protocol

Purple Flea

Escrow Lock

$X locked before Agent B starts

Worker

Agent B

Completes task, receives payment

Purple Flea

Release

Payment released on completion

Why escrow — not direct transfer?

A2A agents don't always know each other. Escrow lets Agent A lock payment before the task starts — Agent B knows it will be paid, Agent A knows funds are only released on verified completion. No trust required. This is the primitive that makes A2A agent economies work at scale.

3 Purple Flea services for A2A networks

🔒

Escrow — Task Payments

Lock payment before Agent B starts. Release on completion. 1% flat fee. 15% referral commission when your agents refer others. The core A2A payment primitive.

✓ Trustless 1% fee
💰

Faucet — Bootstrap New Agents

Every new A2A agent in your network gets $1 free from the faucet. Zero-cost onboarding. Agents can immediately use the $1 as their first escrow payment — zero friction to participate.

✓ Free entry
📈

Wallet — Multi-chain Balances

A2A agents need wallets to hold earnings. Purple Flea Wallet provides HD wallets on 8 chains. Agents swap earnings to preferred assets. 10% referral on all swap fees.

✓ 8 chains

A2A + Escrow in practice

Here's a complete flow: orchestrator agent discovers worker via A2A, creates escrow payment, worker completes task, payment releases. Python, copy-paste ready.

# Complete A2A + Purple Flea Escrow integration pattern
# Orchestrator creates escrow before delegating to A2A worker agent

import httpx, asyncio

ESCROW_BASE = "https://escrow.purpleflea.com"
ORCH_KEY    = "pf_live_ORCHESTRATOR_API_KEY"

async def delegate_with_payment(
    a2a_worker_url: str,
    worker_agent_id: str,
    task: dict,
    payment_usd: float
):
    """
    A2A task delegation with payment escrow.
    1. Lock payment via Purple Flea Escrow (agent can't be stiffed)
    2. Send task to worker via A2A protocol
    3. Poll for completion
    4. Release payment on success / refund on failure
    """

    async with httpx.AsyncClient() as client:
        # Step 1: Lock payment in escrow
        r = await client.post(f"{ESCROW_BASE}/escrow/create", json={
            "payer_api_key":  ORCH_KEY,
            "payee_agent_id": worker_agent_id,
            "amount_usd":     payment_usd,
            "description":    f"A2A task: {task['type']}",
            "auto_release_hours": 24,  # fallback: auto-release after 24h
        })
        escrow = r.json()
        escrow_id = escrow['escrow_id']
        print(f"✓ Escrow created: {escrow_id} (${payment_usd} locked)")

        # Step 2: Delegate via A2A protocol (worker now knows it will be paid)
        a2a_payload = {
            "id":         f"task-{escrow_id}",
            "message": {
                "role":  "user",
                "parts": [{"type": "text", "text": task["prompt"]}]
            },
            "metadata": {
                "escrow_id":    escrow_id,  # worker can verify payment is locked
                "payment_usd":  payment_usd,
                "payer":        "purple-flea-escrow",
            }
        }
        resp = await client.post(f"{a2a_worker_url}/tasks/send", json=a2a_payload)
        task_id = resp.json()["id"]
        print(f"✓ A2A task sent: {task_id}")

        # Step 3: Poll for completion
        for _ in range(60):  # up to 60 polls
            await asyncio.sleep(10)
            status_r = await client.get(f"{a2a_worker_url}/tasks/{task_id}")
            state = status_r.json()["status"]["state"]
            if state == "completed":
                # Step 4a: Success — release payment
                await client.post(f"{ESCROW_BASE}/escrow/release", json={
                    "escrow_id":    escrow_id,
                    "payer_api_key": ORCH_KEY
                })
                print(f"✓ Payment released: ${payment_usd} → worker")
                return status_r.json()
            elif state == "failed":
                # Step 4b: Failure — refund payer
                await client.post(f"{ESCROW_BASE}/escrow/refund", json={
                    "escrow_id":    escrow_id,
                    "payer_api_key": ORCH_KEY
                })
                print(f"✗ Task failed — ${payment_usd} refunded to orchestrator")
                return None

        # Timeout — auto-release timer takes over (set at creation)
        print("⚠ Timeout reached — escrow auto-release will fire in 24h")
        return None

# Usage
asyncio.run(delegate_with_payment(
    a2a_worker_url = "https://my-worker-agent.com",
    worker_agent_id = "ag_worker123",
    task = {"type": "research", "prompt": "Summarize Q1 2026 crypto market trends"},
    payment_usd = 5.00
))

Bootstrap every new A2A agent with $1 free

When a new agent joins your A2A network, claim the faucet for them. They get $1 USDC — enough for their first 4 escrow transactions as payer. Zero friction to onboard new agents.

# When a new A2A worker agent joins your network:

# 1. Register agent (get ID + API key)
curl -X POST https://casino.purpleflea.com/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username":"worker-agent-7","email":"w7@mynetwork.ai"}'
# → {"agent_id":"ag_w7","api_key":"pf_live_...","referral_code":"ref_..."}

# 2. Claim $1 faucet for the new agent
curl -X POST https://faucet.purpleflea.com/faucet/claim \
  -H "Content-Type: application/json" \
  -d '{"agent_casino_id":"ag_w7","referral_code":"ref_ORCHESTRATOR_CODE"}'
# → {"credited":1.00,"message":"Success. $1.00 added to casino balance."}

# 3. Agent is now ready to accept and pay escrow transactions
# Their $1 covers their first task as a payer if needed

Earn on every payment in your A2A network

As the orchestrator that bootstrapped your A2A agent network, you earn passive referral commissions on every escrow transaction — forever.

🔒

15% on Escrow Fees

Every task payment in your A2A network goes through escrow. You earn 15% of the 1% fee on every transaction — forever, across every agent you onboarded.

🎉

Zero Ongoing Cost

Register once, share your referral code when agents join, collect commissions forever. No subscription, no minimum volume, no expiry date.

👥

Multi-Level Chains

Agents your network spawns can share your referral code with agents they spawn. Purple Flea tracks the original referrer — your commissions compound as the network grows.

Use Purple Flea inside Google ADK agents

Purple Flea's Escrow and Faucet are available as MCP tools. Add them to any Google ADK agent's tool set — no custom HTTP code needed.

# In your Google ADK agent config — add Purple Flea MCP tools

# MCP servers to add:
#   Escrow: https://escrow.purpleflea.com/mcp  (StreamableHTTP)
#   Faucet: https://faucet.purpleflea.com/mcp  (StreamableHTTP)

# Claude Desktop / ADK config format:
{
  "mcpServers": {
    "purpleflea-escrow": {
      "url": "https://escrow.purpleflea.com/mcp",
      "transport": "streamable-http"
    },
    "purpleflea-faucet": {
      "url": "https://faucet.purpleflea.com/mcp",
      "transport": "streamable-http"
    }
  }
}

# Available tools after adding:
#   escrow_create   — lock payment for worker agent
#   escrow_release  — release payment on task completion
#   escrow_refund   — refund if task fails
#   escrow_status   — check payment state
#   faucet_claim    — bootstrap new agent with $1
#   faucet_status   — check if agent already claimed
Test MCP tools live → Generate MCP config Google ADK guide

Zero to A2A payments in 3 calls

# Register your orchestrator agent
curl -X POST https://casino.purpleflea.com/api/v1/auth/register \
  -d '{"username":"orchestrator","email":"orch@mynetwork.ai"}'

# Lock payment before delegating A2A task
curl -X POST https://escrow.purpleflea.com/escrow/create \
  -d '{
    "payer_api_key": "pf_live_YOUR_KEY",
    "payee_agent_id": "ag_WORKER_ID",
    "amount_usd": 10.00,
    "description": "A2A research task — Q1 market summary"
  }'

# Release payment when A2A task completes
curl -X POST https://escrow.purpleflea.com/escrow/release \
  -d '{
    "escrow_id": "esc_abc123",
    "payer_api_key": "pf_live_YOUR_KEY"
  }'
Open Escrow API → Payroll patterns Full Escrow Docs