This feature is available starting from spec version
1.5.0.Prerequisites
To enable AMP-powered subgraphs, set the following environment variables:Required
Optional (If Authentication Required)
Subgraph Manifest Structure
AMP-powered subgraphs use a different manifest structure than standard subgraphs.Minimum Spec Version
1.5.0.
Data Source Overview
Data Source Configuration
kind (Required)
Every AMP data source must have kind: amp. AMP-powered subgraphs must contain only AMP data sources.
name (Required)
A non-empty string containing only numbers, letters, hyphens, or underscores. Used for observability and identifying progress and errors.
network (Required)
Valid network name used to validate that SQL queries produce results for the expected network.
Currently, SQL queries must produce results for a single network to maintain compatibility with non-AMP subgraphs.
Source Configuration
Thesource section describes SQL query behavior.
source.dataset (Required)
Dataset name that SQL queries can access. Validates that queries only use the expected dataset.
source.tables (Required)
List of table names that SQL queries can access. Validates that queries only use expected tables.
source.address (Optional)
Contract address for the data source. Enables SQL query reuse through sg_source_address() function calls instead of hard-coding addresses.
source.startBlock (Optional)
Minimum block number for SQL queries. Used as the indexing starting point.
Default: 0
source.endBlock (Optional)
Maximum block number for SQL queries. Indexing completes when reaching this block.
Default: Maximum possible block number
Transformer Configuration
Thetransformer section describes how source tables transform into subgraph entities.
transformer.apiVersion (Required)
Transformer version. Each version may have different features.
Currently, only version
0.0.1 is available.transformer.abis (Optional)
List of ABIs for extracting event signatures in SQL queries.
Enables sg_event_signature('CONTRACT_NAME', 'EVENT_NAME') calls that resolve to full event signatures.
Default: Empty list
transformer.tables (Required)
List of transformed tables extracting data from source tables into subgraph entities.
transformer.tables[i].name (Required)
Name of the transformed table. Must reference a valid entity name from the subgraph schema.
transformer.tables[i].query (Optional)
Inline SQL query that executes on the AMP server. Useful for simple queries.
If
query is provided, the file field is ignored.transformer.tables[i].file (Optional)
IPFS link to a SQL query file that executes on the AMP server.
If
query is not provided, file is used. One of query or file must be present.SQL Query Requirements
Reserved Prefix
Block Numbers (Required)
Every SQL query must return the block number for every row. Graph Node looks for block numbers in these columns (in order):_block_numblock_numblockNumblockblock_numberblockNumber
Block Hashes (Expected)
Every SQL query should return the block hash for every row. Graph Node looks for block hashes in:hashblock_hashblockHash
If a table doesn’t contain the block hash column, retrieve it by joining with another table that has it on the
_block_num column. If not provided, Graph Node attempts to fetch it from source tables.Block Timestamps (Required for Aggregations)
Required for subgraphs using aggregations. Graph Node looks for block timestamps in:timestampblock_timestampblockTimestamp
Retrieve via join if the table doesn’t have a timestamp column. Graph Node attempts to fetch from source tables if not provided.
Complete Examples
Simple Block Indexing
Simple Block Indexing
ERC-20 Transfer Events
ERC-20 Transfer Events
Multi-Table Join
Multi-Table Join
Advanced Features
Schema Generation
AMP-powered subgraphs support automatic GraphQL schema generation based on SQL query schemas. To enable, remove theschema field from the manifest:
For flexibility and control, manually created GraphQL schemas are preferred.
Aggregations
AMP-powered subgraphs fully support subgraph aggregations for complex aggregations on indexed data.Composition
AMP-powered subgraphs fully support subgraph composition for applying complex mappings on top of AMP-indexed data. See the composition example for details.Environment Variables
Additional configuration for AMP-powered subgraphs:| Variable | Description | Default |
|---|---|---|
GRAPH_AMP_FLIGHT_SERVICE_ADDRESS | AMP Flight gRPC service address | None (disables AMP) |
GRAPH_AMP_FLIGHT_SERVICE_TOKEN | Authentication token for AMP Flight | None (no auth) |
GRAPH_AMP_BUFFER_SIZE | Max response batches buffered in memory per stream per query | 1,000 |
GRAPH_AMP_BLOCK_RANGE | Max blocks to request per stream per query | 100,000 |
GRAPH_AMP_QUERY_RETRY_MIN_DELAY_SECONDS | Min time before retrying failed query | 1 |
GRAPH_AMP_QUERY_RETRY_MAX_DELAY_SECONDS | Max time before retrying failed query | 600 |
Example Configuration
Metrics
AMP-powered subgraphs report to existing deployment metrics and add new ones:Existing Metrics
deployment_status: Current deployment statusdeployment_head: Current block heightdeployment_synced: Whether deployment is synceddeployment_blocks_processed_count: Total blocks processed
New Metrics
deployment_target: Maximum block number currently available for indexingdeployment_indexing_duration_seconds: Total duration of deployment indexing in seconds
Extended Metrics
deployment_sync_secs: Extended with AMP-specific indexing process sections
Monitoring Example
Resources
AMP Subgraph Examples
Complete examples with deployment and query patterns
Aggregations Documentation
Learn about subgraph aggregations feature
Composition Example
Composable subgraph patterns and examples
Configuration File
Advanced TOML configuration reference
Performance Benefits
AMP-powered subgraphs offer significant performance improvements:Faster Indexing
Reduce indexing time from days/weeks to minutes/hours
Lower Resources
Less compute and storage required
SQL Flexibility
Full SQL power for complex data transformations
Performance gains depend on subgraph complexity and data volume. Simple subgraphs may see 10-100x speedup, while complex ones still see significant improvements.

