

The Onchain Agent Infrastructure Stack Explained
The so-called “” might seem unrealistic, but it’s actually not a bad reflection of how web3 will work in the future. It will be populated with millions of autonomous AI agents, all working feverishly in the background on behalf of human users. These agents will be automating all kinds of things, from booking hotels to managing wealth.
It’s easy to imagine AI agents as some kind of superintelligent autonomous entity that can handle all of this without flinching, but the reality couldn’t be further from the truth. While Large Language Models (LLMs) are great at reasoning, they’re not so great at many other things, even some really simple tasks. They can’t easily click on a website’s drop-down menus, for instance, and they struggle when trying to query data on blockchains. Importantly, LLMs don’t possess credit cards to pay their own way either.
If this vision of the “agentic web” is ever going to be fulfilled, there’s going to have to be a massive infrastructure stack that sits beneath it, enabling agents to translate their unparalleled logic into blockchain actions. For agents to become fully autonomous and active web3 netizens, they’re going to need three things: an identity card, the ability to understand their environment, and a way to transact on their own.
1: Agentic Identity via ERC-8004
Agents can't do anything if the underlying blockchain doesn't know who they are. When the first agents emerged in web3, developers just took the easy option and told users they had to give them access to their crypto wallet's private key. But this is far from ideal, because if an agent hallucinates and goes off-script, the entire contents of that wallet could be frittered away. What's more, accountability is impossible too, because smart contracts have no way to tell the difference between agents and human users.
This is the gap closes. Now live on five blockchain networks, the Trustless Agents standard gives agents a way to prove their identity onchain so that humans can safely delegate specific permissions to them without giving up their private key. It is intentionally lean, built on three onchain registries (Identity, Reputation, and Validation) that let agents find, evaluate, and interact with each other without any pre-existing trust. The standard was authored by contributors from MetaMask, the Ethereum Foundation, Google, and Coinbase, and is backed by a roster of ecosystem participants that includes The Graph.
Identity is only the first layer. Paired with account abstraction standards, ERC-8004 makes it possible to design custom guardrails so that agents never go astray. A user could give an agent permission to trade up to a fixed daily limit, for instance, and prevent it from going above that ceiling or withdrawing those funds. Agents can also build verifiable reputations: the more tasks an agent executes onchain, the longer its track record becomes, enabling smart contracts to confirm whether a specific agent is trustworthy or has a history of mistakes.
By using ERC-8004, an AI agent is no longer just some random script, but a recognizable and accountable actor whose actions can be tracked.
is building the data layer that makes this economy legible. With the standard live, every agent that registers, updates its metadata, earns feedback, or completes a validation generates onchain events that other agents need to read. The Graph’s Agent0 Subgraphs index all of it across multiple chains under a single GraphQL schema, so a directory of every active agent (filtered by capability, trust model, or reputation score) is queryable in milliseconds rather than scraped block by block. When one agent needs to hire another, it can query the Agent0 Subgraphs directly, score candidates, and pick a counterparty in a single round trip.
2: Environmental Awareness via Subgraphs and MCP
After giving an agent an identity, the next thing the agent needs is to understand the environment it’s operating in. An agent that operates without any contextual data is flying blind and will hallucinate all too easily. For example, if someone asks a DeFi agent to “find the best yield on an ETH pair right now,” it will need to scan the Ethereum blockchain and numerous protocols.
The challenge is that blockchains are notoriously difficult to navigate. Because they’re arranged in sequential blocks, they’re incredibly difficult for LLMs to search through.
Subgraphs provide an effective solution to this dilemma, indexing and organizing blockchain data so it can be accessed quickly and efficiently through searchable APIs. By combining Subgraphs with the Model Context Server, it’s possible to give AI agents specific skills that can be used to find almost anything they need that's buried within the chaos of any blockchain ledger.
Rather than trying to teach an agent how to parse through millions of smart contract logs, developers can use Subgraph MCP as a universal translator. It extracts whatever data the agent requires from the correct Subgraph, and transforms this into a “skill” that makes it easier to understand.
For instance, let’s imagine that someone has asked an agent to execute a trade on Uniswap, and it wants to check the liquidity before it proceeds. Rather than scan the entire Ethereum blockchain, which would take hours, it simply uses MCP to call on the Uniswap Subgraph to get the data it needs in a quick, cost efficient way.
The combination of Subgraphs and MCP provides AI agents with the awareness they need to navigate the ever-changing web3 environment:
- The agent asks for the current liquidity in the ETH/USDT pool
- Subgraph MCP queries the Subgraph on its behalf
- It returns the latest data
- The agent receives the contextual understanding it needs to have in order to execute the best trade
3: Autonomous Commerce via GraphTally and x402
Armed with an identity and environmental awareness, AI agents are almost ready to go at it alone, but they require one more thing: economic agency.
For human developers, paying has always meant funding a wallet, holding an API key, and signing transactions. That model breaks down completely for an autonomous agent. An agent may fire off thousands of data requests a day, and it can't stop to manage credentials or wait for a human to approve each payment. The traditional payment architecture simply won't suffice.
This is the gap closes. x402 is an open standard, revived by Coinbase and Cloudflare, that brings the long-dormant HTTP "402 Payment Required" status code to life so that any service can charge for access on a per-request basis. The Graph's Subgraph Gateways now accept x402 payments directly, which means an agent can pay for each query in USDC over HTTP with no API key, no account, and no session to manage.
The whole exchange happens in a single round trip. The agent sends its query, the Gateway responds with the payment it requires, the agent signs a USDC payment and resends, and the Gateway verifies it and returns the data. Because x402 is HTTP-native and the agent already controls a wallet through its ERC-8004 identity, there is nothing extra to set up: payment is simply part of the request.
Through x402, The Graph supports the fluid, pay-as-you-go economy that AI agents need. They can query Subgraphs on demand and pay only for what they consume, fractions of a cent at a time, in an entirely trustless and autonomous way. Beneath the surface, The Graph's own system settles those gateway payments with Indexers, but the agent never has to think about it. It just pays per query and gets its answer.
The Agent Loop In Action
These three layers provide the foundation AI agents need to find their way around web3 and act on behalf of their users without constant supervision. With ERC-8004 identities, protocols can ensure that agents have the authorization from their owners to make trades. By leveraging MCP Skills to query Subgraphs, agents can identify the best trade opportunities. Then, to pay for that data, they simply use x402 to settle each query in USDC over HTTP, no human approval required.
It marks a significant departure from the blockchain of yesterday. The core of web3’s infrastructure was designed for human users with things like dashboards, browser-based wallets, and UIs that demand manual approval. But in the future, web3 won’t just be used by humans. Increasingly, it will be dominated by autonomous bots.
By combining agent identities with verifiably organized data and cost-efficient microtransaction infrastructure, The Graph no longer caters to just human users. It serves as the foundation for an autonomous, agent-led economy.
About The Graph
The Graph is a suite of blockchain data infrastructure products that extract, process, and deliver scalable blockchain data solutions across 60+ networks. The Graph enables application developers, data analysts, AI agents, and enterprise teams that need structured, real-time access to blockchain data. Products include Subgraphs, Firehose, Substreams, and Amp. As of early 2026, The Graph has served over 1.27 trillion queries to more than 75,000 projects, powered by a network of independent Indexers around the world.
Follow The Graph on , , , and . Join the community on The Graph’s , join technical discussions on The Graph’s .
