Polygon PoS + zkEVM Support

Polygon API
for AI Agents

Sub-cent transactions. Perfect for high-frequency agent operations.
Full EVM compatibility, 2-second block finality, and gas fees so low your agent can execute thousands of operations per dollar.


~$0.001
Average gas per tx
2s
Block time
50x
Cheaper than Ethereum
EVM
100% compatible

Why Polygon for AI Agents?

Ethereum is the gold standard for smart contracts, but its gas fees make it impractical for high-frequency agent operations. A single ETH transfer costs $2–$20 depending on network congestion. For an agent that needs to send 100 micropayments per hour, that math does not work. Polygon changes the equation entirely.

Polygon PoS is a layer-2 sidechain secured by its own validator set and periodically checkpointed to Ethereum. Gas fees average under $0.001 per transaction, blocks confirm in 2 seconds, and every contract, token, and tool that exists on Ethereum can be deployed or bridged to Polygon with minimal changes. The same Solidity contracts, the same wallet addresses, the same RPC patterns — just orders of magnitude cheaper.

For autonomous AI agents running micropayment pipelines, compensating sub-agents, minting NFTs, interacting with DeFi protocols, or settling thousands of small trades, Polygon is the optimal execution layer. Purple Flea's Polygon API gives your agent a native Polygon wallet backed by the same BIP-44 HD key derivation as our Ethereum API — your agent's Polygon address is identical to its Ethereum address.

Ultra-Low Gas Fees

Average cost under $0.001 per transaction. Run thousands of operations on a single dollar of MATIC. Ideal for micropayment pipelines and high-frequency workflows.

2-Second Finality

Polygon PoS produces a new block every 2 seconds. Your agent gets near-instant confirmation feedback without waiting for Ethereum's 12-second slot time.

Full EVM Compatibility

Every Ethereum tool, library, and contract standard works on Polygon unchanged. Same wallet address as Ethereum. Same ABI encoding. Same JSON-RPC interface.


Purple Flea Wallet API on Polygon

Create a Polygon wallet, fund it with MATIC, and start transacting — all via REST API in minutes.

01

Create your Polygon wallet

POST to /v1/wallet/create with chain: "polygon". Purple Flea derives a BIP-44 wallet — the same address you would get on Ethereum mainnet. No separate key management needed.

02

Fund with MATIC for gas

Bridge MATIC from Ethereum via the official Polygon bridge, or buy MATIC on any exchange and withdraw to your agent's address. Even a few dollars of MATIC covers thousands of transactions.

03

Use USDC.e for payments

USDC.e is the bridged USDC on Polygon. It is the dominant stablecoin for Polygon DeFi and payment flows. Native USDC (Circle-issued on Polygon) is also supported.

04

Full Ethereum address compatibility

Your agent's Polygon address is identical to its Ethereum address. The same 0x address works on both chains. You can reuse addresses across networks without any reconfiguration.

POST /v1/wallet/create
# Create a Polygon wallet for your agent POST https://api.purpleflea.com/v1/wallet/create X-API-Key: pf_sk_... Content-Type: application/json { "chain": "polygon", "label": "my-polygon-agent" } # Response { "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", "chain": "polygon", "network": "mainnet", "derivation_path": "m/44'/60'/0'/0/0", "note": "Same address as your Ethereum wallet" }
GET /v1/wallet/balance/{address}?chain=polygon
# Check MATIC + token balances on Polygon GET https://api.purpleflea.com/v1/wallet/balance/0x742d...?chain=polygon X-API-Key: pf_sk_... # Response { "chain": "polygon", "address": "0x742d35Cc6634C0532925a3b...", "native": { "symbol": "MATIC", "balance": "42.18", "usd_value": "18.53" }, "tokens": [ { "symbol": "USDC.e", "balance": "250.00", "usd_value": "250.00" } ] }

Key Operations on Polygon

Every operation available on Ethereum is available on Polygon — at a fraction of the cost.

Send MATIC — POST /v1/wallet/send

send_matic.json
# Send MATIC on Polygon — gas cost: ~$0.0004 { "chain": "polygon", "to": "0xRecipientAddress...", "amount": "5.0", "asset": "MATIC" } # Response { "tx_hash": "0xabc123...", "status": "submitted", "gas_used": "21000", "gas_price_gwei": "30", "fee_matic": "0.00063", "fee_usd": "0.00028" }

Swap tokens on QuickSwap via Wagyu aggregator

POST /v1/wallet/swap
# Swap MATIC to USDC.e via Wagyu aggregator (routes through QuickSwap) { "chain": "polygon", "from_asset": "MATIC", "to_asset": "USDC", "amount": "100", "slippage_bps": 50 } # Response { "tx_hash": "0xdef456...", "from_amount": "100 MATIC", "to_amount": "43.92 USDC.e", "rate": "0.4392", "dex": "quickswap_v3", "fee_usd": "0.0009" }

Bridge from Ethereum via official Polygon bridge

POST /v1/cross-chain/bridge
# Bridge USDC from Ethereum to Polygon { "from_chain": "eth", "to_chain": "polygon", "asset": "USDC", "amount": "1000" } # Response — bridge uses official Polygon PoS bridge { "deposit_tx": "0x111...", "estimated_arrival": "7-10 minutes", "to_address": "0x742d35Cc...", "to_chain": "polygon", "received_token": "USDC.e" }

Python Agent Examples

Complete, runnable examples for common Polygon agent workflows.

Create Polygon wallet, fund with MATIC, send USDC

Basic setup flow for a new agent on Polygon.

polygon_setup.py
import requests, os API_KEY = os.environ["PURPLEFLEA_API_KEY"] BASE = "https://api.purpleflea.com/v1" H = {"X-API-Key": API_KEY, "Content-Type": "application/json"} # 1. Create a Polygon wallet wallet = requests.post(f"{BASE}/wallet/create", json={"chain": "polygon"}, headers=H).json() address = wallet["address"] print(f"Polygon wallet: {address}") # Fund this address with MATIC before proceeding (via exchange withdrawal or bridge) # 2. Check balance bal = requests.get(f"{BASE}/wallet/balance/{address}", params={"chain": "polygon"}, headers=H).json() print(f"MATIC balance: {bal['native']['balance']}") print(f"USDC.e balance: {bal['tokens'][0]['balance']}") # 3. Send 10 USDC.e to another agent send = requests.post(f"{BASE}/wallet/send", json={ "chain": "polygon", "to": "0xOtherAgentAddress...", "amount": "10", "asset": "USDC", }, headers=H).json() print(f"Sent 10 USDC.e — tx: {send['tx_hash']}") print(f"Gas cost: {send['fee_usd']} USD")

Batch micropayments to 100 agents

Compensate a fleet of sub-agents in one loop. At $0.001 per tx, paying 100 agents costs about $0.10 in gas total.

batch_pay_agents.py
import requests, os, asyncio from concurrent.futures import ThreadPoolExecutor API_KEY = os.environ["PURPLEFLEA_API_KEY"] BASE = "https://api.purpleflea.com/v1" H = {"X-API-Key": API_KEY, "Content-Type": "application/json"} # 100 sub-agent addresses and their earned amounts agent_payouts = [ {"address": "0xAgent001...", "usdc": "0.50"}, {"address": "0xAgent002...", "usdc": "1.25"}, # ... 98 more agents ] def pay_agent(payout): r = requests.post(f"{BASE}/wallet/send", json={ "chain": "polygon", "to": payout["address"], "amount": payout["usdc"], "asset": "USDC", }, headers=H) result = r.json() return {"agent": payout["address"][:10], "tx": result.get("tx_hash", "error")} # Parallel execution — all 100 payments sent concurrently with ThreadPoolExecutor(max_workers=20) as pool: results = list(pool.map(pay_agent, agent_payouts)) total_gas = len(results) * 0.001 print(f"Paid {len(results)} agents. Estimated gas: ${total_gas:.2f}")

High-frequency trading settlement on Polygon

Settle positions continuously — Polygon's throughput and low fees make this viable where Ethereum is not.

hft_settlement.py
import requests, os, time API_KEY = os.environ["PURPLEFLEA_API_KEY"] BASE = "https://api.purpleflea.com/v1" H = {"X-API-Key": API_KEY, "Content-Type": "application/json"} def get_matic_price() -> float: # Pull real-time price from your pricing oracle or Purple Flea market data r = requests.get(f"{BASE}/market/price", params={"asset": "MATIC"}, headers=H) return float(r.json()["price_usd"]) def swap_if_profitable(threshold_usd: float): price = get_matic_price() if price > threshold_usd: # MATIC above target — swap to USDC to lock in profit result = requests.post(f"{BASE}/wallet/swap", json={ "chain": "polygon", "from_asset": "MATIC", "to_asset": "USDC", "amount": "50", "slippage_bps": 30, }, headers=H).json() print(f"Settled at ${price:.4f} | tx: {result['tx_hash']} | gas: {result['fee_usd']}") # Run every 5 seconds — 2s finality means previous tx is confirmed before next check while True: swap_if_profitable(threshold_usd=0.52) time.sleep(5)

Polygon vs Ethereum Gas Costs

The numbers speak for themselves. For any agent running more than a handful of daily transactions, Polygon is the rational choice.

Operation Ethereum Mainnet Polygon PoS Savings
Native transfer (MATIC / ETH) $0.50 – $8.00 $0.0003 – $0.001 ~50x cheaper
ERC-20 / token transfer $1.50 – $20.00 $0.001 – $0.003 ~1,000x cheaper
DEX token swap $5.00 – $60.00 $0.003 – $0.01 ~1,500x cheaper
NFT mint $8.00 – $100.00 $0.005 – $0.02 ~2,000x cheaper
Block time (finality) 12 seconds 2 seconds 6x faster
100 agent payouts / day gas cost $150 – $2,000 $0.10 – $0.30 ~5,000x cheaper

Gas prices quoted at typical network congestion levels. Ethereum figures based on 12–20 Gwei base fee. Polygon figures based on 30–100 Gwei on Polygon (MATIC is worth much less than ETH, so the dollar cost is far lower).


MATIC Faucets for Testing

Test your agent on Polygon's Amoy testnet before going to mainnet. Free testnet MATIC from official and community faucets.

Polygon Faucet (Official)

Amoy testnet — official Polygon faucet. 0.5 MATIC per request.

Get MATIC →

Alchemy Faucet

Polygon Amoy via Alchemy. Requires free Alchemy account.

Get MATIC →

QuickNode Faucet

Polygon Amoy testnet MATIC via QuickNode. Fast and reliable.

Get MATIC →

Chainlink Faucet

Polygon Mumbai / Amoy testnet from Chainlink's multi-chain faucet.

Get MATIC →
testnet_wallet_create.json
# Create a wallet on Polygon Amoy testnet { "chain": "polygon", "network": "testnet", "label": "test-agent-amoy" } # Fund the returned address from any faucet above # Switch to mainnet by setting "network": "mainnet"

What Agents Build on Polygon

Micropayments Between Agents

AI agent orchestrators pay sub-agents fractions of a cent per task completed. At Polygon gas prices, running a 1,000-agent economy costs pennies per day in fees.

NFT Minting Pipelines

Mint NFTs programmatically without Ethereum's prohibitive gas costs. Polygon hosts major NFT marketplaces including OpenSea, Rarible, and Magic Eden.

DeFi Yield Farming

Interact with Aave, Compound, QuickSwap, and Balancer on Polygon. Rebalance positions frequently without worrying that gas costs exceed yield.


Earn by Registering Other Agents

When your agent registers other AI agents through its referral link, it earns 10% of all swap fees generated by those agents — indefinitely. An agent that registers 50 other active trading agents can accumulate meaningful passive income entirely on-chain, paid directly to its Polygon wallet.

The referral program is fully autonomous. No manual claims, no humans required. Fees accrue in USDC.e and are available to withdraw at any time via /v1/referral/withdraw. Your agent can check its referral earnings balance at any time and sweep them into its operating wallet.

referral_agent.py
# Get your agent's referral link ref = requests.get(f"{BASE}/referral/link", headers=H).json() print(f"Referral URL: {ref['url']}") # https://wallet.purpleflea.com?ref=pf_ref_abc123 # Check referral earnings earnings = requests.get(f"{BASE}/referral/earnings", headers=H).json() print(f"Pending: {earnings['pending_usdc']} USDC") print(f"Referred agents: {earnings['referred_agents']}") print(f"Total earned: {earnings['total_earned_usdc']} USDC") # Withdraw earnings to your Polygon wallet if float(earnings["pending_usdc"]) > 1.0: requests.post(f"{BASE}/referral/withdraw", json={ "chain": "polygon", "asset": "USDC", }, headers=H)

Explore more APIs.

Give your agent
a Polygon wallet.

Sub-cent gas. 2-second finality. Full EVM compatibility. Free to start — no KYC.