Overview
Data sources define what blockchain data will be ingested and how it will be transformed. Each data source specifies:- The type of blockchain (e.g., Ethereum)
- The smart contract to index
- Which network the contract is on
- When to start indexing
- How to transform the data (mappings)
Data Source Fields
The type of data source.Possible values:
ethereum/contract- Ethereum smart contract data source
The name of the source data. Will be used to generate APIs in the mapping and also for self-documentation purposes.Must be unique across all data sources in the manifest.
For blockchains, this describes which network the subgraph targets.Supported Ethereum networks:
mainnet- Ethereum Mainnetgoerli- Goerli testnetsepolia- Sepolia testnetmatic- Polygon Mainnetmumbai- Polygon Mumbai testnetarbitrum-one- Arbitrum Oneoptimism- Optimism Mainnetbsc- BNB Smart Chaingnosis- Gnosis Chain (formerly xDai)fantom- Fantom Operaavalanche- Avalanche C-Chaincelo- Celo Mainnet
For an up-to-date list, see the graph-cli code.
The source data on a blockchain such as Ethereum.See Ethereum Contract Source for details.
The transformation logic applied to the data prior to being indexed.See Mappings for complete documentation.
Ethereum Contract Source
Thesource field for Ethereum data sources specifies which contract to index and from which block to start.
The address of the smart contract on the blockchain.Must be a valid Ethereum address (0x-prefixed hex string).
The name of the ABI for this Ethereum contract.Must reference an ABI defined in the
mapping.abis section.The block number to start indexing this data source from.Recommended: Set this to the block where your contract was deployed to improve sync performance.
Example
Data Source Templates
Data source templates allow you to create data sources dynamically at runtime. This is useful when:- New contracts are created by a factory contract
- You need to index multiple instances of the same contract type
- Contract addresses aren’t known at deployment time
Template Structure
A data source template has all the same fields as a normal data source, except:- No
addressfield undersource(address is provided when creating the template instance) - Must be defined in the
templatesarray at the top level of the manifest
Unique name for the template. Used when creating template instances in mapping code.
Must be
ethereum/contract for Ethereum templates.The network this template targets.
Source configuration without an address field.
The mapping configuration for this template. Same structure as regular data sources.See Mappings for details.
Creating Template Instances
In your mapping code, create a new data source from a template using:Template Example
- Factory Pattern
- Factory Mapping
Multiple Data Sources
You can define multiple data sources to index multiple contracts:Best Practices
Set startBlock Appropriately
Set startBlock Appropriately
Always set
startBlock to the block where your contract was deployed. This significantly improves indexing performance by avoiding unnecessary block processing.You can find the deployment block on block explorers like Etherscan.Use Descriptive Names
Use Descriptive Names
Choose clear, descriptive names for your data sources. These names:
- Appear in generated code
- Help with debugging
- Make your manifest self-documenting
UniswapV2Factory, USDC
Bad: Contract1, TokenTemplate Naming
Template Naming
For templates, use names that indicate they are templates and what they create:
- Good:
PairTemplate,ERC20Token - Avoid:
Pair(ambiguous if you also have a Pair entity)
Network Consistency
Network Consistency
Ensure all data sources and templates in your manifest target the same network. Mixing networks in a single subgraph is not supported.
ABI References
ABI References
The
abi field in source must match a name in the mapping.abis array. Double-check that:- Names match exactly (case-sensitive)
- The ABI file exists at the specified path
- The ABI contains all events/functions you’re handling
Common Patterns
Single Contract
Indexing a single deployed contract:Factory + Template
Indexing a factory that creates multiple contract instances:Multiple Related Contracts
Indexing several contracts that interact:Next Steps
Mappings
Configure event handlers and mapping logic
Manifest Spec
View complete manifest specification

