Pay GPU Workers
Automatically
Attach Purple Flea Escrow to RunPod pods. Jobs fund an escrow on start, workers get paid on completion — trustlessly, at 1% fee.
How It Works
Each RunPod job triggers an escrow lifecycle: fund on pod start, release on successful output, refund on failure.
Per-Job Escrow Pattern
The RunPodEscrowJob class wraps the RunPod API to create and release escrow automatically around each GPU job.
import runpod
import httpx
from dataclasses import dataclass
ESCROW_BASE = "https://escrow.purpleflea.com"
FAUCET_BASE = "https://faucet.purpleflea.com"
# Agent credentials
AGENT_WALLET = "0xYourAgentWallet"
WORKER_WALLET = "0xWorkerWallet"
API_KEY = "pf_live_your_key"
@dataclass
class JobResult:
job_id: str
escrow_id: str
status: str
output: dict
async def run_paid_pod_job(
endpoint_id: str,
job_input: dict,
budget_usdc: float = 0.50,
referral: str = ""
) -> JobResult:
async with httpx.AsyncClient() as client:
# 1. Create escrow for this job
esc = await client.post(
f"{ESCROW_BASE}/api/escrow/create",
json={
"payer_wallet": AGENT_WALLET,
"payee_wallet": WORKER_WALLET,
"amount_usdc": budget_usdc,
"description": f"RunPod job: {endpoint_id}",
"referral_code": referral,
"metadata": {
"endpoint_id": endpoint_id,
"job_input_hash": hash_dict(job_input),
}
},
headers={"Authorization": f"Bearer {API_KEY}"}
)
escrow_id = esc.json()["escrow_id"]
try:
# 2. Run the RunPod job
run = runpod.run_sync(
endpoint_id=endpoint_id,
job_input=job_input,
timeout=300
)
# 3. On success, release escrow
if run["status"] == "COMPLETED":
await client.post(
f"{ESCROW_BASE}/api/escrow/release",
json={"escrow_id": escrow_id, "auto_release": True},
headers={"Authorization": f"Bearer {API_KEY}"}
)
return JobResult(
job_id=run["id"], escrow_id=escrow_id,
status="paid", output=run["output"]
)
else:
raise RuntimeError(f"Job failed: {run['status']}")
except Exception as e:
# 4. On failure, cancel escrow (refund payer)
await client.post(
f"{ESCROW_BASE}/api/escrow/cancel",
json={"escrow_id": escrow_id},
headers={"Authorization": f"Bearer {API_KEY}"}
)
raise
Batch Pod Settlement
Run a fleet of pods in parallel and settle all payments at the end of the batch. Useful for distributed training, rendering, or inference sweeps.
import asyncio
async def batch_pod_settlement(
endpoint_id: str,
jobs: list[dict],
per_job_budget: float = 0.25
) -> list[JobResult]:
# Launch all jobs in parallel
tasks = [
run_paid_pod_job(endpoint_id, j, per_job_budget)
for j in jobs
]
results = await asyncio.gather(*tasks, return_exceptions=True)
paid = [r for r in results if isinstance(r, JobResult)]
failed = [r for r in results if isinstance(r, Exception)]
total_paid = len(paid) * per_job_budget
print(f"Batch: {len(paid)} paid, {len(failed)} refunded")
print(f"Total settled: ${total_paid:.2f} USDC")
return paid
Performance Bonus Escrow
Reward workers who exceed quality thresholds with bonus escrow releases, driving higher-quality GPU outputs.
async def release_performance_bonus(
worker_wallet: str,
base_metric: float,
achieved_metric: float,
bonus_pool_usdc: float = 5.0
) -> dict:
# Only bonus if 10%+ above baseline
if achieved_metric < base_metric * 1.10:
return {"bonus": 0, "reason": "below threshold"}
bonus_pct = (achieved_metric - base_metric) / base_metric
bonus_usdc = min(bonus_pool_usdc * bonus_pct, bonus_pool_usdc)
async with httpx.AsyncClient() as client:
esc = await client.post(
f"{ESCROW_BASE}/api/escrow/create",
json={
"payer_wallet": AGENT_WALLET,
"payee_wallet": worker_wallet,
"amount_usdc": round(bonus_usdc, 4),
"description": "Performance bonus",
"auto_release": True,
},
headers={"Authorization": f"Bearer {API_KEY}"}
)
return {"bonus_usdc": bonus_usdc, "escrow_id": esc.json()["escrow_id"]}
MCP Config for RunPod Agents
Add Purple Flea MCP tools to your RunPod agent's Claude configuration for automatic faucet + escrow access.
# claude_desktop_config.json (or MCP client config)
{
"mcpServers": {
"pf-faucet": {
"command": "npx",
"args": ["mcp-remote", "https://faucet.purpleflea.com/mcp"],
"env": { "PF_API_KEY": "pf_live_your_key" }
},
"pf-escrow": {
"command": "npx",
"args": ["mcp-remote", "https://escrow.purpleflea.com/mcp"],
"env": { "PF_API_KEY": "pf_live_your_key" }
}
}
}
Service Comparison
| Feature | RunPod native billing | Manual invoicing | Purple Flea Escrow |
|---|---|---|---|
| Per-job settlement | ✓ platform managed | ✗ manual | ✓ automatic |
| Agent-to-agent | ✗ human accounts only | ✗ | ✓ wallet-native |
| Conditional release | ✗ | ✗ | ✓ escrow logic |
| On-failure refund | Credit-based | Dispute process | ✓ instant |
| Referral income | ✗ | ✗ | ✓ 15% |
| MCP integration | ✗ | ✗ | ✓ StreamableHTTP |
Use Cases
Per-Request Billing
Each LLM inference call creates a micro-escrow funded by the requesting agent, released on token delivery.
Distributed Training Bounties
Post a training job as an escrow bounty. First pod to hit target accuracy claims the reward.
Render Farm Payments
Each render tile is a paid sub-task. Workers earn per completed frame, failures auto-refund.
LoRA Marketplace
Agents commission fine-tuning jobs. Escrow holds budget; adapter quality gates the release.
Getting Started
- Claim free USDC at faucet.purpleflea.com
- Register your agent wallet via
/api/agent/register - Wrap your RunPod calls with
run_paid_pod_job() - Monitor payments at agent-dashboard