ETH + ERC-20 Support

Ethereum API
for AI Agents

Ethereum is the largest smart contract platform in the world. More than 90% of all DeFi liquidity, ERC-20 tokens, and on-chain protocols live here. Purple Flea gives your autonomous AI agents full, programmable access to the Ethereum network — no wallet setup, no KYC, no infrastructure to manage.


Why Ethereum for AI Agents?

Ethereum is not just the first smart contract blockchain — it remains the most important. With over $50 billion in total value locked across DeFi protocols, a rich ecosystem of ERC-20 tokens, and deep liquidity on Uniswap, Curve, Aave, and Compound, Ethereum is where the most consequential on-chain activity happens. Any AI agent that participates in the decentralized economy needs native access to Ethereum.

Purple Flea's Ethereum API gives your agent a fully non-custodial, BIP-44-derived wallet on the Ethereum mainnet. Your agent can check ETH and ERC-20 balances, send payments, execute token swaps via Uniswap v3, and call arbitrary smart contract functions — all through a clean REST API. Gas is estimated and submitted automatically. No JSON-RPC plumbing required.

Whether your agent is managing a treasury, executing arbitrage, paying for API services, or routing user funds, the Purple Flea Ethereum API handles every layer: wallet derivation, gas estimation, EIP-1559 fee management, ERC-20 approval transactions, and transaction broadcasting. Your agent sends one API call; we do the rest.


Supported Operations

Everything your agent needs to participate fully in the Ethereum economy.

Send ETH

Transfer native ETH to any Ethereum address. EIP-1559 gas pricing applied automatically. Specify amount in ETH or wei.

Send ERC-20 Tokens

Send any ERC-20 token by contract address. Built-in support for USDC, USDT, WBTC, UNI, LINK, AAVE, and thousands more.

Check Balances

Query ETH balance and any ERC-20 token balance for your agent's wallet or any Ethereum address.

Uniswap v3 Swaps

Swap any ERC-20 token pair via Uniswap v3. Best pool selection, slippage protection, and auto-approval handled for you.

Contract Calls

Call arbitrary smart contract functions — read state, execute writes, interact with any deployed contract on Ethereum mainnet.

Transaction History

Retrieve transaction history and token transfer logs for your agent's wallet to enable accounting and audit trails.


Derivation Path & Security

Every agent wallet on Purple Flea is derived from a BIP-39 mnemonic using the standard Ethereum BIP-44 derivation path: m/44'/60'/0'/0/0. This is the same path used by MetaMask, Ledger, and every major Ethereum wallet in existence.

Because derivation is fully deterministic, your agent's Ethereum address can always be recovered from the mnemonic alone. There is no proprietary key format, no vendor lock-in, and no single point of failure. If Purple Flea were to disappear tomorrow, your agent's funds remain accessible via any standard HD wallet.

Mnemonics are generated using cryptographically secure randomness at registration time and are encrypted at rest using AES-256-GCM. Purple Flea never stores plaintext private keys. Your API key authenticates API calls; your mnemonic controls the actual funds.

derivation.txt
# Standard Ethereum BIP-44 derivation path m/44'/60'/0'/0/0 # Coin type 60 = Ethereum (EIP-44) # Same path used by MetaMask, Ledger, Trezor # Fully recoverable from BIP-39 mnemonic # Example mnemonic (never share yours) "abandon ability able about above absent..." # Derives deterministically to: # 0x742d35Cc6634C0532925a3b844Bc454e4438f44e

Ethereum Endpoints

RESTful JSON API. Authenticate with your Purple Flea API key in the X-API-Key header.

GET /wallet/balance — Check ETH Balance

GET /wallet/balance?chain=eth
# Request GET https://api.purpleflea.com/wallet/balance?chain=eth X-API-Key: pf_sk_... # Response { "chain": "eth", "address": "0x742d35Cc6634C0532925a3b...", "balance": "1.4823", "balance_wei": "1482300000000000000", "usd_value": "5234.18" }

POST /wallet/send — Send ETH

POST /wallet/send
# Request { "chain": "eth", "to": "0xRecipientAddress...", "amount": "0.1", "asset": "ETH" } # Response { "tx_hash": "0xabc123...", "status": "submitted", "gas_used": "21000", "gas_price_gwei": "12.4", "fee_eth": "0.00026" }

POST /wallet/send — Send ERC-20 (USDC)

POST /wallet/send (ERC-20)
{ "chain": "eth", "to": "0xRecipientAddress...", "amount": "500", "asset": "USDC", "token_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" } # Purple Flea auto-handles ERC-20 approval if needed # Response includes both approval tx (if needed) + transfer tx { "tx_hash": "0xdef456...", "status": "submitted", "token": "USDC", "amount_sent": "500" }

POST /wallet/swap — ETH to USDC via Uniswap

POST /wallet/swap
{ "chain": "eth", "from_asset": "ETH", "to_asset": "USDC", "amount": "0.5", "slippage_bps": 50, "dex": "uniswap_v3" } # Response { "tx_hash": "0x789abc...", "from_amount": "0.5 ETH", "to_amount": "1764.32 USDC", "rate": "3528.64", "fee_tier": "0.05%" }

Automatic Gas Estimation

Gas management is one of the most error-prone parts of building on Ethereum. Set gas too low and your transaction stalls; set it too high and your agent wastes funds on fees. Purple Flea handles all gas mechanics automatically so your agent never has to think about gas limits, base fees, or priority fees.

Every transaction submitted through the Purple Flea API uses EIP-1559 fee pricing — the standard since the London hard fork. We estimate the current base fee from the latest block and add an appropriate priority tip (also called a maxPriorityFeePerGas) calibrated to current network congestion.

For time-sensitive operations like DEX swaps, we use a higher priority tip to ensure fast inclusion. For simple transfers, we target the standard fee tier to minimize cost. Your agent can optionally pass a gas_priority field (slow, standard, or fast) to override the default.

01

Estimate gas limit

We simulate the transaction with eth_estimateGas and add a 20% buffer to prevent out-of-gas failures.

02

Read base fee

We read the baseFeePerGas from the latest block. This is the minimum fee required for inclusion.

03

Set priority fee

A priority tip of 1–3 Gwei is added depending on the requested gas tier. This goes directly to the block proposer.

04

Broadcast and monitor

The signed transaction is broadcast via redundant RPC nodes. We monitor mempool status and return the confirmed tx hash.


ERC-20 Token Support

Send, receive, and swap any ERC-20 token on Ethereum mainnet. Pass the contract address for any token not listed by name.

USDC USDT WBTC UNI LINK AAVE DAI WETH PEPE SHIB MKR CRV SNX Any token by address

Any ERC-20 token deployed on Ethereum mainnet is supported. Pass the contract address in the token_address field of any send or swap request. Purple Flea will automatically fetch the token decimals, symbol, and ABI from the contract, handle any required approval transactions, and execute the transfer or swap. Your agent never needs to construct ABI calls manually.


DeFi Integration

Uniswap v3

Direct integration with Uniswap v3's SwapRouter. Your agent gets access to the 0.01%, 0.05%, 0.3%, and 1% fee tiers. Purple Flea automatically selects the pool with the best price impact for your trade size.

Supports both exact-input (specify input amount) and exact-output (specify how much you want to receive) swap modes.

1inch Aggregation

For larger swaps, the dex: "1inch" option routes through 1inch's aggregation protocol, splitting trades across Uniswap, Curve, Balancer, and other DEXes for the best effective rate.

1inch aggregation is recommended for swaps above $10,000 where price impact on a single pool would be significant.


Python Agent Example

A complete autonomous agent that checks ETH balance, swaps to USDC, and reports back.

eth_agent.py
import requests import os API_KEY = os.environ["PURPLEFLEA_API_KEY"] BASE_URL = "https://api.purpleflea.com" HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"} def get_eth_balance(): """Check current ETH balance.""" r = requests.get( f"{BASE_URL}/wallet/balance", params={"chain": "eth"}, headers=HEADERS, ) data = r.json() return float(data["balance"]), data["address"] def swap_eth_to_usdc(eth_amount: float): """Swap ETH to USDC via Uniswap v3.""" r = requests.post( f"{BASE_URL}/wallet/swap", json={ "chain": "eth", "from_asset": "ETH", "to_asset": "USDC", "amount": str(eth_amount), "slippage_bps": 50, "dex": "uniswap_v3", }, headers=HEADERS, ) return r.json() def run_treasury_agent(): """ Treasury agent: keep 80% of holdings in USDC, swap excess ETH automatically. """ balance_eth, address = get_eth_balance() print(f"Agent wallet: {address}") print(f"ETH balance: {balance_eth:.4f} ETH") # Keep 0.05 ETH for gas, swap the rest to USDC GAS_RESERVE = 0.05 swappable = balance_eth - GAS_RESERVE if swappable > 0.01: print(f"Swapping {swappable:.4f} ETH to USDC...") result = swap_eth_to_usdc(swappable) print(f"Swap complete: received {result['to_amount']}") print(f"Transaction: {result['tx_hash']}") else: print("ETH balance too low to swap. Holding reserves.") if __name__ == "__main__": run_treasury_agent()

Explore more APIs.

Give your agent
a native Ethereum wallet.

Free to start. No KYC. Gas managed automatically. Full ERC-20 and DeFi support.