Operations

Agent Gas Station โ€”
Auto-Fund Gas Fees

The most embarrassing failure mode for an autonomous agent: a profitable trade can't execute because the wallet ran out of gas. Purple Flea's gas station keeps every agent wallet topped up automatically, across all eight supported chains.

Add Auto Gas Funding โ†’ Read Docs

The Gas Problem

Every on-chain transaction requires native tokens to pay validator fees โ€” ETH on Ethereum, MATIC on Polygon, SOL on Solana, BNB on BSC. These are completely separate from the USDC or other stablecoins your agent uses for trading. An agent can have $50,000 in USDC and still be unable to execute a trade if the ETH balance is zero.

The separation of gas and capital is a common source of agent failures.

Gas tokens and trading capital must be managed independently. An agent that carefully tracks its USDC balance but ignores its ETH balance will fail at the worst possible moment โ€” during high volatility when transaction costs spike and trade windows are narrow.

โŒ
Failed Transactions

Trades revert on-chain because there's not enough ETH to pay gas. The opportunity is missed and the failed tx wastes a small amount of gas anyway.

๐Ÿ”’
Stuck Funds

An agent with USDC but no ETH literally cannot move its own money. Funds become inaccessible until a human manually sends gas โ€” defeating the purpose of autonomous operation.

โฐ
Missed Opportunities

Arbitrage windows last seconds. A zero-gas agent watching a profitable spread close without being able to act is the most expensive failure mode there is.

๐Ÿ””
Alert Fatigue

Without automation, owners receive low-gas alerts but must manually respond. In a fleet of 50 agents across 4 chains, this becomes unmanageable overhead.

Auto-Topup Configuration

Configure per-agent gas topup rules in a single API call. Set a master funding wallet, define minimum thresholds and topup amounts per chain, and the gas station handles the rest.

import purpleflea

gas = purpleflea.GasStationClient(api_key="YOUR_KEY")

# Configure gas auto-topup for all your agents
station = gas.configure_topup(
    funding_wallet="0xYourMasterWallet",  # ETH source
    agents=[
        {
            "agent_id": "agent_trader_001",
            "chain": "ethereum",
            "min_balance_eth": 0.02,     # Topup if below 0.02 ETH
            "topup_amount_eth": 0.1,     # Add 0.1 ETH each time
        },
        {
            "agent_id": "agent_defi_001",
            "chain": "polygon",
            "min_balance_matic": 5.0,
            "topup_amount_matic": 20.0,
        },
        {
            "agent_id": "agent_solana_001",
            "chain": "solana",
            "min_balance_sol": 0.1,
            "topup_amount_sol": 0.5,
        }
    ],
    check_frequency_minutes=15,
    alert_webhook="https://myagent.example.com/gas-alert"
)

print(f"Gas station: {station['station_id']}")
print(f"Monitoring {station['agent_count']} agents")

Gas Price Optimization

Routine topups don't need to happen immediately. The gas station monitors network congestion and schedules topups during low-fee windows, reducing overhead costs by up to 60%.

๐Ÿ“‰
Congestion-Aware Scheduling

When an agent's balance is above the critical threshold (typically 2x minimum), the gas station waits for a low-congestion period โ€” often early morning UTC when US and Asian markets are inactive โ€” to execute the topup at minimum cost.

โšก
Priority Mode for Urgent Topups

When a balance drops to the critical minimum threshold, the gas station immediately executes a topup at the prevailing gas price โ€” no waiting for congestion windows. Speed takes priority over cost optimization at critical levels.

๐Ÿ“ฆ
Batch Topups Across Agents

When multiple agents on the same chain need topups within the same scheduling window, the gas station batches them into a single transaction where possible, further reducing per-agent gas overhead.

๐ŸŽฏ
EIP-1559 Optimization (Ethereum)

On Ethereum, the gas station uses EIP-1559 transactions with dynamically calculated priority fees. It monitors the fee history and sets the priority fee at the median of the last 20 blocks โ€” enough to confirm without overpaying.

Emergency Gas Reserve

Even with monitoring active, a burst of transaction activity can drain a gas balance faster than the 15-minute check interval catches it. The emergency reserve system handles this case.

If a transaction fails on-chain with an "out of gas" error, the gas station receives an immediate webhook notification from the chain's RPC provider. Within 30 seconds, an emergency topup is dispatched at high priority, bypassing the normal scheduling queue.

The failed transaction is also automatically resubmitted after the emergency topup confirms, so your agent doesn't need to detect and retry the failure itself. The entire failure-recover-retry cycle is invisible to the agent's main logic.

EMERGENCY Transaction failed: out of gas
DISPATCHING Emergency topup: 0.1 ETH โ†’ agent_trader_001
CONFIRMED Topup confirmed in 18s ยท Resubmitting failed tx
SUCCESS Original transaction confirmed ยท Agent operational
Agent Gas Health Dashboard

Real-time gas balance view across your entire agent fleet.

agent_trader_001 (ETH) 0.08 ETH
agent_defi_001 (MATIC) 6.2 MATIC
agent_solana_001 (SOL) 0.45 SOL
agent_bsc_001 (BNB) 0.003 BNB
Auto-Suspend on Low Funding Wallet

If the master funding wallet itself runs low, the gas station sends a high-priority alert and suspends non-critical topups to preserve reserves for emergency events only.

Multi-Chain Gas Management

Eight chains, each with different native tokens, gas mechanics, and typical costs. The gas station handles them all under a unified API.

Chain Native Token Typical Gas / Tx Recommended Min Balance Check Interval
Ethereum ETH $3 โ€” $15 0.05 ETH 15 min
Polygon MATIC $0.001 โ€” $0.05 5 MATIC 15 min
Arbitrum ETH $0.05 โ€” $0.30 0.005 ETH 15 min
Solana SOL $0.0005 โ€” $0.01 0.1 SOL 15 min
BSC BNB $0.05 โ€” $0.50 0.01 BNB 15 min
Optimism ETH $0.01 โ€” $0.10 0.005 ETH 15 min
Avalanche AVAX $0.05 โ€” $0.30 0.05 AVAX 15 min
Base ETH $0.01 โ€” $0.05 0.002 ETH 15 min
8
Chains supported
15 min
Standard check interval
<30s
Emergency topup dispatch

Add Auto Gas Funding to Your Agent

One configuration call. Eight chains covered. Your agent will never miss a trade because of an empty gas tank again.