Ethereum Mainnet
- Type
- mainnet
- Protocol
- ethereum
- Identifier
- mainnet
- Chain ID
- eip155:1
- Native Currency
- ETH
Indexing Data on Ethereum
Ethereum is the original programmable, EVM Layer 1 and the largest smart-contract network by developer activity, total value locked, and application diversity, secured by proof-of-stake with ETH as its native token. The Graph can index that onchain activity, including DEX swaps, pools, and liquidity; lending and borrowing positions; token transfers and holder balances; and contract events. That powers DeFi frontends, analytics dashboards, block explorers, portfolio trackers, and onchain agents without teams having to run their own indexing infrastructure.
Ethereum is supported by The Graph in two ways:
- You can publish Subgraphs to The Graph Network — where Indexers sync and serve data while consumers manage their service in Subgraph Studio.
- You can also consume Substreams — a real-time streaming engine for high-throughput use cases via The Graph Market, Pinax Network, and Data Nexus.
Indexing Ethereum with Subgraphs
Getting smart contract data is hard. You write your own indexer, run your own database, and handle chain reorganizations yourself. The Graph removes that work, giving you an open API, called a Subgraph, that you query with GraphQL.
Ethereum is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your Ethereum contract, define the entities you want, and Indexers on The Graph Network keep those entities current and queryable.
Quick Start: Build Your Own Subgraph
Building a Subgraph for Ethereum takes three steps:
- Initialize a Subgraph project from your Ethereum contract.
- Publish it to The Graph Network for decentralized indexing.
- Query it over GraphQL with an API key.
See the Subgraph pricing page for current query rates and free-tier limits.
Step 1: Initialize your Subgraph project
Install the Graph CLI with the package manager you prefer:
1# npm2npm install -g @graphprotocol/graph-cli@latest34# or yarn5yarn global add @graphprotocol/graph-cliVerify the install:
1graph --versionInitialize from your Ethereum contract:
1graph initThe CLI walks you through a set of prompts:
- Protocol: choose
ethereum. Ethereum is EVM-compatible. - Subgraph slug: an identifier for your Subgraph, for example
my-ethereum-subgraph. - Directory: where the project is scaffolded.
- Ethereum network: select
mainnetfrom the list of supported networks. - Contract address: the address of the contract you want to index. Find it on etherscan.io.
- ABI: if the CLI cannot fetch the ABI, export it from your build artifacts or the Etherscan contract page. Supply it as a JSON file.
- Start block: the block your contract was deployed at. Set this so indexing does not scan from genesis. The explorer shows the deployment block.
- Contract name: the name of your contract.
- Index contract events as entities: set this to
true. The CLI then scaffolds entities and mappings for every emitted event.
network value for Ethereum is mainnet. graph init recognizes it directly, so you can select it from the list of supported networks. You can also set the network field manually in subgraph.yaml (next step).Step 2: Write and build your Subgraph
You work with three files:
- Manifest:
subgraph.yamldefines which data sources your Subgraph indexes. - Schema:
schema.graphqldefines the entities you want to query. - Mappings:
src/mapping.tsuses AssemblyScript that translates on-chain events into your entities.
Point the manifest at Ethereum:
1dataSources:2- kind: ethereum3 name: MyContract4 network: mainnet5 source:6 address: '0xYourEthereumContractAddress'7 abi: MyContract8 startBlock: 123456 # your contract's deployment blockFor a full walkthrough of schema and mapping authoring, see Creating a Subgraph.
Generate types and build:
1graph codegen && graph buildOptional: verify locally before publishing. You can test indexing with a local Graph Node pointed at an RPC endpoint for Ethereum. In your docker-compose.yml, set the Ethereum environment to Ethereum:
1environment:2ethereum: 'mainnet:https://eth.rpc.service.pinax.network'Create and deploy to your local node:
1graph create --node http://localhost:8020/ my-ethereum-subgraph2graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-ethereum-subgraphQuery the local endpoint until your entities look right, then publish.
Step 3: Publish & Curate on The Graph Network
Publishing is an on-chain action that:
- makes your Subgraph available for decentralized Indexers to index,
- makes it publicly searchable and queryable in Graph Explorer,
- and makes it available for Curators to add signal.
Build, then publish from the Graph CLI:
1graph codegen && graph build2graph publishA browser window opens. Connect your wallet, add metadata (name, description, image), and publish your Subgraph. The --protocol-network flag refers to where The Graph’s protocol contracts live (Arbitrum One), not to Ethereum.
During the publish transaction, you can add 500 GRT in curation signal to save on gas fees. Signal tells Indexers that your Subgraph is worth indexing. Any Subgraph with 500 GRT or more signal will automatically be indexed; without signal, no Indexer is incentivized to pick up your Subgraph.
Step 4: Query your Subgraph
After you publish, open your Subgraph in Graph Explorer and copy its query URL from the Query button.
- Create an API key from the API Keys dashboard at thegraph.com/studio. This dashboard handles API keys and billing for The Graph Network.
- Send GraphQL queries to the query URL with your API key.
See the Subgraph pricing page for query rates, and Querying The Graph for the full query API.
Indexing Ethereum with Substreams
Substreams is a parallelized, real-time streaming engine for extracting and transforming blockchain data. Where a Subgraph indexes into a hosted GraphQL API, Substreams lets you consume high-throughput data directly or via 10+ supported sinks. Ethereum is served with the extended EVM block model, so Substreams modules have access to full transaction, call, and event data. Modules are written in Rust and composed into reusable packages.
Find an Existing Module on Substreams.dev
Before writing any code, check the Substreams Registry for a package that already does what you need. The registry hosts community- and team-built modules — DEX trades, token transfers, contract events, and more — that you can run as-is or compose into your own pipeline. Search for the protocol or data you want on Ethereum; if a module fits, you can consume its output directly or import it as a dependency in your own project.
Develop Your Own Substreams Module
If no existing module fits, you can build one. The Substreams Quick Start is the full walkthrough. In short:
- Install the Substreams CLI and get a key at [thegraph.market](https://thegraph.market/) (no personal information required).
- Scaffold a project with
substreams initand choose the EVM path, pointing it at your Ethereum contract. - Write your extraction and transformation logic in Rust, then run
substreams build. - Stream the output with
substreams gui(orsubstreams run) to iterate, then publish your package to the Substreams Registry to reuse or share it.