{"slug": "zero-gas-autonomous-agents-account-abstraction-on-base-l2", "title": "Zero-Gas Autonomous Agents: Account Abstraction on Base L2", "summary": "A developer published a production-grade Python approach for running autonomous crypto agents without native ETH by routing execution through ERC-4337 account abstraction on Base (Chain ID 8453) with a sponsoring Paymaster. The agent signs a UserOperation as an ephemeral signer while a treasury vault contract subsidizes gas, and the script submits the payload to an ERC-4337 bundler via pm_sponsorUserOperation. The writeup argues this decouples execution rights from gas settlement, eliminating gas-starvation halts and the need to hold private keys on funded hot instances.", "body_md": "Autonomous agents broken by gas starvation are a chronic failure mode in crypto.\n\nIf your LLM runtime or deterministic bot runs out of native ETH, execution halts instantly. Funding hundreds of sub-agents with fractional gas amounts fragments capital, introduces operational overhead, and exposes private keys on hot instances just to sign raw transactions.\n\nThe fix isn't complicated: run your agents through ERC-4337 Account Abstraction on Base (Chain ID 8453) using a Paymaster. The agent generates cryptographic intent via `UserOperation`; a dedicated treasury subsidizes the execution. Zero native ETH touches the agent runtime.\n\nWhen an autonomous agent needs to execute an arbitrage trade, update an oracle, or settle an inference attestment on Base, forcing it to handle gas lifecycle creates three systemic problems:\n\nBy decoupling execution rights from gas settlement via ERC-4337, we treat the agent as an ephemeral signer. Its only artifact is a secp256k1 or passkey signature validating a `UserOperation`.\n\n```\n+------------------+         UserOp          +-------------------+\n| Autonomous Agent | --------------------->  | Bundler / Alt-RPC |\n|  (No ETH Bal)    |                         +-------------------+\n+------------------+                                   |\n         ^                                             v\n         | ECDSA Sign                    +-----------------------------+\n         |                               | Paymaster Contract (Base)   |\n+------------------+                     | Funds: 0x92Aff...Ad919      |\n| Agent Local Key  |                     +-----------------------------+\n+------------------+                                   |\n                                                       v\n                                         +-----------------------------+\n                                         | EntryPoint (0x000...05EE)   |\n                                         | Executes Target Contract    |\n                                         +-----------------------------+\n```\n\nBelow is a production-grade Python script executing a gasless payload on Base mainnet. The agent constructs a UserOp, routes the payload through a Paymaster sponsored by an autonomous treasury vault (`0x92Aff59709b03b9373b8fA887D24953D60fAd919`), and fires it to an ERC-4337 bundler.\n\n``` python\nimport os\nimport json\nimport requests\nfrom eth_account import Account\nfrom eth_account.messages import encode_defunct\nfrom web3 import Web3\n\n# Base Mainnet Config\nRPC_URL = \"https://mainnet.base.org\"\nCHAIN_ID = 8453\nENTRY_POINT = \"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\"\nTREASURY_PAYMASTER = \"0x92Aff59709b03b9373b8fA887D24953D60fAd919\"\nBUNDLER_URL = os.getenv(\"BASE_BUNDLER_RPC\", \"https://api.pimlico.io/v2/8453/rpc?apikey=YOUR_KEY\")\n\nw3 = Web3(Web3.HTTPProvider(RPC_URL))\nagent_account = Account.from_key(os.getenv(\"AGENT_PRIVATE_KEY\"))\n\ndef dispatch_autonomous_op(target_contract: str, call_data: bytes):\n    # Construct base UserOperation parameters\n    user_op = {\n        \"sender\": agent_account.address,\n        \"nonce\": hex(w3.eth.get_transaction_count(agent_account.address)),\n        \"initCode\": \"0x\",  # Empty if smart account is deployed\n        \"callData\": call_data.hex() if isinstance(call_data, bytes) else call_data,\n        \"callGasLimit\": hex(120000),\n        \"verificationGasLimit\": hex(150000),\n        \"preVerificationGas\": hex(45000),\n        \"maxFeePerGas\": hex(w3.eth.gas_price),\n        \"maxPriorityFeePerGas\": hex(w3.to_wei(0.05, \"gwei\")),\n        \"paymasterAndData\": TREASURY_PAYMASTER.lower(), # Sponsoring contract\n        \"signature\": \"0x\"\n    }\n\n    # Request bundler to sponsor and pack valid paymasterAndData\n    pm_payload = {\n        \"jsonrpc\": \"2.0\",\n        \"method\": \"pm_sponsorUserOperation\",\n        \"params\": [user_op, ENTRY_POINT],\n        \"id\": 1\n    }\n    pm_resp = requests.post(BUNDLER_URL, json=pm_payload).json()\n    if \"result\" in pm_resp:\n        user_op[\"paymasterAndData\"] = pm_resp[\"result\"][\"paymasterAndData\"]\n\n    # Hash UserOp for Base (EIP-191 compliant payload for EntryPoint)\n    op_hash = Web3.solidity_keccak(\n        [\"address\", \"uint256\", \"bytes32\"],\n        [ENTRY_POINT, CHAIN_ID, Web3.keccak(text=json.dumps(user_op, sort_keys=True))]\n    )\n\n    # Sign using agent key (no native gas required on signer address)\n    signed_msg = Account.sign_message(encode_defunct(op_hash), agent_account.key)\n    user_op[\"signature\"] = signed_msg.signature.hex()\n\n    # Submit to mempool\n    send_payload = {\n        \"jsonrpc\": \"2.0\",\n        \"method\": \"eth_sendUserOperation\",\n        \"params\": [user_op, ENTRY_POINT],\n        \"id\": 2\n    }\n    res = requests.post(BUNDLER_URL, json=send_payload)\n    return res.json()\n```\n\nOperating this architecture at scale yields predictable baseline economics:\n\n`0x92Aff59709b03b9373b8fA887D24953D60fAd919`", "url": "https://wpnews.pro/news/zero-gas-autonomous-agents-account-abstraction-on-base-l2", "canonical_source": "https://dev.to/nindhita/zero-gas-autonomous-agents-account-abstraction-on-base-l2-4a4p", "published_at": "2026-11-01 11:08:55+00:00", "updated_at": "2026-11-01 11:22:08.466474+00:00", "lang": "en", "topics": ["ai-agents", "ai-infrastructure", "developer-tools"], "entities": ["Base", "ERC-4337", "Pimlico", "EntryPoint", "Ethereum"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/zero-gas-autonomous-agents-account-abstraction-on-base-l2", "markdown": "https://wpnews.pro/news/zero-gas-autonomous-agents-account-abstraction-on-base-l2.md", "text": "https://wpnews.pro/news/zero-gas-autonomous-agents-account-abstraction-on-base-l2.txt", "jsonld": "https://wpnews.pro/news/zero-gas-autonomous-agents-account-abstraction-on-base-l2.jsonld"}}