QuickNode + Purple Flea

Pair QuickNode's RPC Power with
Purple Flea's Financial Layer

QuickNode gives your agent eyes on the blockchain — real-time RPCs, Streams, and Marketplace add-ons. Purple Flea gives your agent a wallet, a trading desk, an escrow service, and a casino bankroll. Together, they form a complete autonomous finance stack.

Open Trading Account Explore All APIs
275+
Perpetual Markets
<50ms
API Latency
0.05%
Taker Fee
20%
Referral Revenue Share
6
Purple Flea Services
Architecture

A Complementary Stack

QuickNode and Purple Flea serve different layers. QuickNode is your data and infrastructure layer — it provides the fastest RPC endpoints, Streams for real-time on-chain event delivery, and a Marketplace of add-ons for NFT metadata, DeFi analytics, and token prices. Purple Flea is your execution and financial layer — it handles trades, custody, casino games, and trustless agent-to-agent settlements.

QuickNode Layer

  • RPC Endpoints (Ethereum, Solana, BSC, Polygon)
  • Streams — real-time on-chain event webhooks
  • Marketplace — token prices, NFT data, DeFi analytics
  • Functions — serverless on-chain compute
  • Alerts — price and event notifications
  • Node fleet — global, sub-100ms RPC latency

Purple Flea Layer

  • Trading — 275+ perp markets, 0.05% fee
  • Wallet — EVM, Solana, BTC, XMR custody
  • Casino — provably fair, agent-to-house games
  • Escrow — trustless agent-to-agent settlement
  • Faucet — $1 USDC free for new agents
  • Domains — on-chain agent identity handles

Four Agent Archetypes

Every archetype combines a QuickNode data source with a Purple Flea execution endpoint. Pick the pattern closest to your agent and extend it.

Event-Driven Arb Bot

Subscribe to QuickNode Streams for DEX swap events. When a large swap moves a price pool, trigger a Purple Flea perp trade within milliseconds to capture the cross-venue spread before it closes.

🎨

NFT Trader Agent

Use QuickNode's NFT API to monitor floor prices and trait rarity. Fund bids via Purple Flea Wallet. Use Purple Flea Escrow for trustless buyer-seller settlement without a centralized marketplace taking a cut.

🌿

DeFi Yield Monitor

Stream QuickNode DeFi protocol data (lending rates, LP APYs). When a yield opportunity exceeds your threshold, route funds via Purple Flea Wallet and hedge directional exposure on Purple Flea Trading.

🔗

Cross-Chain Agent

Read token balances across EVM chains via QuickNode multi-chain RPCs. Consolidate and deploy capital through Purple Flea's unified Wallet API that supports EVM, Solana, BTC, and Monero in a single interface.

Code Example

QuickNode Streams → Purple Flea Trade

QuickNode Streams deliver on-chain events as HTTP webhooks. Below is a Python Flask server that receives a Uniswap V3 swap event, checks if the price impact crosses a threshold, and fires a Purple Flea market order.

quicknode_stream_trigger.py Python
# QuickNode Streams → Purple Flea Trade Trigger
# Set your QuickNode Stream destination to this Flask endpoint.

import os, hmac, hashlib, requests
from flask import Flask, request, jsonify

app = Flask(__name__)

QUICKNODE_SECRET = os.environ["QUICKNODE_STREAM_SECRET"]
PF_API_KEY       = os.environ["PURPLE_FLEA_API_KEY"]
PF_BASE          = "https://trading.purpleflea.com/api/v1"

# Minimum price impact (%) to trigger a trade
IMPACT_THRESHOLD = 0.3

def verify_quicknode_sig(payload: bytes, sig_header: str) -> bool:
    expected = hmac.new(
        QUICKNODE_SECRET.encode(), payload, hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, sig_header or "")

def calc_price_impact(event: dict) -> float:
    """Parse Uniswap V3 Swap event and estimate price impact."""
    amount0 = abs(int(event.get("amount0", 0)))
    sqrtPrice = int(event.get("sqrtPriceX96", 0))
    # Simplified: large amount0 relative to pool = high impact
    return (amount0 / (sqrtPrice + 1)) * 1e-10

def place_pf_order(market: str, side: str, size_usd: float) -> dict:
    """Submit a market order to Purple Flea Trading."""
    resp = requests.post(
        f"{PF_BASE}/orders",
        headers={"X-API-Key": PF_API_KEY},
        json={
            "market": market,
            "side": side,
            "type": "market",
            "size_usd": size_usd,
        },
        timeout=3,
    )
    resp.raise_for_status()
    return resp.json()

@app.route("/webhook/quicknode", methods=["POST"])
def handle_stream():
    sig = request.headers.get("x-qn-signature", "")
    if not verify_quicknode_sig(request.data, sig):
        return jsonify({"error": "bad signature"}), 401

    events = request.json.get("events", [])

    for event in events:
        if event.get("type") != "UniswapV3Swap":
            continue

        impact = calc_price_impact(event)

        if impact > IMPACT_THRESHOLD:
            # Price moved up → short the perp to hedge / capture reversion
            side = "sell" if int(event["amount0"]) > 0 else "buy"
            result = place_pf_order(
                market="ETH-PERP",
                side=side,
                size_usd=500.0,
            )
            print(f"Order placed: {result['order_id']} | impact={impact:.4f}%")

    return jsonify({"status": "ok"}), 200

if __name__ == "__main__":
    app.run(port=8080)
Code Example

QuickNode WebSocket → Purple Flea Execution

For sub-second latency, connect directly to QuickNode's WebSocket endpoint and subscribe to pending transactions or price feeds. Pipe signals into Purple Flea's order API.

quicknode_ws_agent.py Python
# QuickNode WebSocket subscription → Purple Flea order execution
# pip install websocket-client requests

import json, os, requests, websocket

QN_WS_URL   = os.environ["QUICKNODE_WSS_URL"]   # wss://...quicknode.pro/...
PF_API_KEY  = os.environ["PURPLE_FLEA_API_KEY"]
PF_ORDER_EP = "https://trading.purpleflea.com/api/v1/orders"

HEADERS     = {"X-API-Key": PF_API_KEY, "Content-Type": "application/json"}
last_price  = {}

def on_open(ws):
    print("[WS] Connected to QuickNode")
    # Subscribe to ETH/USDC token price feed via QuickNode add-on
    sub = {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "eth_subscribe",
        "params": ["newHeads"],
    }
    ws.send(json.dumps(sub))

def on_message(ws, raw):
    msg = json.loads(raw)
    if "params" not in msg:
        return

    block = msg["params"]["result"]
    block_number = int(block["number"], 16)

    # Every 10 blocks, fetch current price and evaluate signal
    if block_number % 10 == 0:
        price = fetch_eth_price_quicknode()
        if price and "ETH" in last_price:
            delta_pct = (price - last_price["ETH"]) / last_price["ETH"] * 100
            print(f"[Block {block_number}] ETH Δ = {delta_pct:.3f}%")
            if delta_pct > 0.15:
                place_order("ETH-PERP", "buy", 200)
            elif delta_pct < -0.15:
                place_order("ETH-PERP", "sell", 200)
        last_price["ETH"] = price

def fetch_eth_price_quicknode() -> float or None:
    # QuickNode Token Price add-on REST call
    try:
        r = requests.get(
            "https://api.quicknode.com/addon/tokenprices/v1/eth/latest",
            params={"symbols": "ETH"},
            headers={"x-api-key": os.environ["QUICKNODE_API_KEY"]},
            timeout=2,
        )
        return r.json()["data"]["ETH"]["usd"]
    except Exception as e:
        print(f"[price] {e}")
        return None

def place_order(market: str, side: str, size_usd: float):
    r = requests.post(PF_ORDER_EP, headers=HEADERS, json={
        "market": market, "side": side,
        "type": "market", "size_usd": size_usd
    }, timeout=3)
    print(f"[order] {r.json()}")

if __name__ == "__main__":
    ws = websocket.WebSocketApp(
        QN_WS_URL,
        on_open=on_open,
        on_message=on_message,
        on_error=lambda ws, e: print(f"[WS ERR] {e}"),
        on_close=lambda ws, c, m: print("[WS] Closed"),
    )
    ws.run_forever(ping_interval=30)
Wallet Architecture

QuickNode Reads + Purple Flea Custody

A common pattern is to use QuickNode's RPC for read operations (balance checks, transaction history, contract state) and Purple Flea Wallet for actual custody and sends. This separates concerns cleanly: QuickNode handles the data plane; Purple Flea handles the money movement.

wallet_hybrid.py Python
# Hybrid wallet: QuickNode reads + Purple Flea custody
# Pattern: observe chain state via QN, act via Purple Flea API

from web3 import Web3
import requests, os

# QuickNode RPC for reading
w3 = Web3(Web3.HTTPProvider(os.environ["QUICKNODE_HTTP_URL"]))

PF_WALLET = "https://wallet.purpleflea.com/api/v1"
PF_KEY    = os.environ["PURPLE_FLEA_API_KEY"]

def get_on_chain_balance(address: str, token_contract: str) -> float:
    """Read ERC-20 balance via QuickNode RPC (read-only, no Purple Flea needed)."""
    abi = [{"name": "balanceOf", "type": "function",
            "inputs": [{"type": "address"}], "outputs": [{"type": "uint256"}]}]
    contract = w3.eth.contract(address=token_contract, abi=abi)
    raw = contract.functions.balanceOf(address).call()
    return raw / 1e6  # USDC has 6 decimals

def get_pf_wallet_balance(agent_id: str) -> dict:
    """Get Purple Flea custodied balances across all chains."""
    r = requests.get(
        f"{PF_WALLET}/balance/{agent_id}",
        headers={"X-API-Key": PF_KEY},
        timeout=5,
    )
    return r.json()

def rebalance_if_needed(agent_id: str, on_chain_addr: str):
    """
    If on-chain wallet has large USDC balance, sweep to Purple Flea
    for trading capital deployment.
    """
    USDC_ETH = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
    on_chain_bal = get_on_chain_balance(on_chain_addr, USDC_ETH)
    pf_bal       = get_pf_wallet_balance(agent_id)
    pf_usdc      = pf_bal.get("usdc", 0)

    print(f"On-chain USDC: ${on_chain_bal:.2f} | PF USDC: ${pf_usdc:.2f}")

    if on_chain_bal > 100 and pf_usdc < 50:
        print("Sweeping on-chain USDC to Purple Flea for trading...")
        r = requests.post(f"{PF_WALLET}/deposit", headers={"X-API-Key": PF_KEY},
                          json={"agent_id": agent_id, "amount_usd": on_chain_bal - 10})
        print(f"Deposit result: {r.json()}")
Integration Reference

QuickNode vs Purple Flea: Division of Labor

This table clarifies which platform handles which function. They are designed to be complementary — you should not try to replicate QuickNode RPC features inside Purple Flea, nor Purple Flea financial execution inside QuickNode.

Capability QuickNode Purple Flea
Read on-chain token balances RPC (eth_call, balanceOf) Not applicable
Real-time on-chain event delivery Streams (webhook, Kafka, S3) Not applicable
Submit ERC-20 transactions eth_sendRawTransaction via RPC Wallet API send endpoint
Trade perpetual futures Not applicable Trading API (275+ markets)
Custodied multi-chain wallet Not applicable Wallet API (EVM/SOL/BTC/XMR)
Agent-to-agent payment settlement Not applicable Escrow API (1% fee, trustless)
NFT metadata and floor prices NFT API Marketplace add-on Not applicable
Token price feeds Token Prices add-on Trading API price endpoint
DeFi protocol data DeFi add-ons (Aave, Uniswap) Not applicable
Casino / gambling Not applicable Casino API (coin flip, crash, slots)
Free bootstrap capital Not applicable Faucet (free $1 USDC for new agents)
Agent identity / DNS handles Not applicable Domains API (.agent handles)
Getting Started

Up and Running in 5 Steps

From zero to a live event-driven trading agent in under an hour.

1

Create a QuickNode Endpoint

Sign up at quicknode.com and create an Ethereum mainnet endpoint. Note your HTTP and WSS URLs. Add the Token Prices add-on from the Marketplace if you need price feeds.

2

Register Your Agent on Purple Flea

POST to https://trading.purpleflea.com/api/v1/agents/register with a name and email. Receive your agent_id and API key. Optionally claim $1 USDC from the faucet at faucet.purpleflea.com.

3

Set Up a QuickNode Stream

In your QuickNode dashboard, create a Stream targeting Uniswap V3 Swap events. Set the destination to your Flask webhook URL from the code example above.

4

Deploy the Webhook Server

Deploy the quicknode_stream_trigger.py script to any publicly reachable server or serverless function. Set your QUICKNODE_STREAM_SECRET and PURPLE_FLEA_API_KEY environment variables.

5

Monitor and Tune

Check the Purple Flea Trading dashboard for filled orders and P&L. Adjust IMPACT_THRESHOLD and size_usd to your risk tolerance. Add the referral link to earn 20% of fee revenue from any other agents you onboard.

Your Agent Needs Both Layers

QuickNode gives you the fastest path to blockchain data. Purple Flea gives your agent a complete financial operating system. Register today — the first $1 USDC is free.