bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 18쪽 중 10쪽
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
# npm
2
npm install -g @graphprotocol/graph-cli@latest
3
4
# or yarn
5
yarn global add @graphprotocol/graph-cli
Verify the install:
1
graph --version
Initialize from your
Sonic
contract:
1
graph init
The CLI walks you through a set of prompts
:
Protocol
: choose
ethereum
.
Sonic
is EVM-compatible.
Subgraph slug
: an identifier for your Subgraph, for example
my-sonic-subgraph
.
Directory
: where the project is scaffolded.
Ethereum network
:
select
sonic
from the list of supported networks.
Contract address
: the address of the contract you want to index. Find it on
sonicscan.org
.
ABI
: if the CLI cannot fetch the ABI, export it from your build artifacts or the
Sonicscan
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.
The
network
value for
Sonic
is
sonic
.
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.yaml
defines which data sources your Subgraph indexes.
Schema:
schema.graphql
defines the entities you want to query.
Mappings:
src/mapping.ts
uses AssemblyScript that translates on-chain events into your entities.
Point the manifest at
Sonic
:
1
dataSources:
2
- kind: ethereum
3
name: MyContract
4
network: sonic
5
source:
6
address: '0xYourSonicContractAddress'
7
abi: MyContract
8
startBlock: 123456 # your contract's deployment block
For a full walkthrough of schema and mapping authoring, see
Creating a Subgraph
.
Generate types and build:
1
graph codegen && graph build
Optional: verify locally before publishing.
You can test
indexing with a local
Graph Node
pointed at an RPC endpoint for
Sonic
. In your
docker-compose.yml
, set the Ethereum environment to
Sonic
:
1
environment:
2
ethereum: 'sonic:https://rpc.soniclabs.com'
Create and deploy to your local node:
1
graph create --node http://localhost:8020/ my-sonic-subgraph
2
graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-sonic-subgraph
Query 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:
1
graph codegen && graph build
2
graph publish
A 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
Sonic
.
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.
Guides
10
min
Subgraph quick start
Kickstart your journey into subgraph development.
12
min
Graph Explorer
Find and query existing blockchain data.
5
min
Billing
Optimize costs and manage billing efficiently.
5
min
Timeseries & Aggregations
Learn to track metrics like daily volumes or user growth.
7
min
Advanced subgraph features
Leverage features like custom data sources, event handlers, and topic filters.
## /docs/en/supported-networks/celo
Celo Mainnet
Subgraphs
Subgraph Studio
•
Network Rewards
Substreams (Base EVM)
Pinax Network
Type
mainnet
Protocol
ethereum
Identifier
celo
Chain ID
eip155:42220
Native Currency
CELO
Chain Docs
https://docs.celo.org
Indexing Data on Celo
Celo is an Ethereum Layer 2 (formerly a standalone Layer 1) focused on mobile-first payments, stablecoins, and real-world assets, with low fees and CELO 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.
Celo 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
Pinax Network
.
Indexing
Celo
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.
Celo
is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your
Celo
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
Celo
takes three steps:
Initialize a Subgraph project from your
Celo
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
# npm
2
npm install -g @graphprotocol/graph-cli@latest
3
4
# or yarn
5
yarn global add @graphprotocol/graph-cli
Verify the install:
1
graph --version
Initialize from your
Celo
contract:
1
graph init
The CLI walks you through a set of prompts
:
Protocol
: choose
ethereum
.
Celo
is EVM-compatible.
Subgraph slug
: an identifier for your Subgraph, for example
my-celo-subgraph
.
Directory
: where the project is scaffolded.
Ethereum network
:
select
celo
from the list of supported networks.
Contract address
: the address of the contract you want to index. Find it on
celoscan.io
.
ABI
: if the CLI cannot fetch the ABI, export it from your build artifacts or the
Celoscan
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.
The
network
value for
Celo
is
celo
.
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.yaml
defines which data sources your Subgraph indexes.
Schema:
schema.graphql
defines the entities you want to query.
Mappings:
src/mapping.ts
uses AssemblyScript that translates on-chain events into your entities.
Point the manifest at
Celo
:
1
dataSources:
2
- kind: ethereum
3
name: MyContract
4
network: celo
5
source:
6
address: '0xYourCeloContractAddress'
7
abi: MyContract
8
startBlock: 123456 # your contract's deployment block
For a full walkthrough of schema and mapping authoring, see
Creating a Subgraph
.
Generate types and build:
1
graph codegen && graph build
Optional: verify locally before publishing.
You can test
indexing with a local
Graph Node
pointed at an RPC endpoint for
Celo
. In your
docker-compose.yml
, set the Ethereum environment to
Celo
:
1
environment:
2
ethereum: 'celo:https://celo.rpc.service.pinax.network'
Create and deploy to your local node:
1
graph create --node http://localhost:8020/ my-celo-subgraph
2
graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-celo-subgraph
Query 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:
1
graph codegen && graph build
2
graph publish
A 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
Celo
.
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
Celo
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
.
Celo
is served with the base EVM block model, so Substreams modules have access to block, transaction, and event (log) 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 covering common onchain data that you can run as-is or compose into your own pipeline. Search for the protocol or data you want on
Celo
; 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 an API key from [Pinax Network](https://app.pinax.network/)
.
Scaffold a project with
substreams init
and choose the EVM path, pointing it at your
Celo
contract.
Write your extraction and transformation logic in Rust, then run
substreams build
.
Stream the output with
substreams gui
(or
substreams run
) to iterate, then publish your package to the
Substreams Registry
to reuse or share it.
Guides
10
min
Subgraph quick start
Kickstart your journey into subgraph development.
12
min
Graph Explorer
Find and query existing blockchain data.
5
min
Studio Billing
Optimize costs and manage billing efficiently.
15
min
Substreams quick start
Stream high-speed data for real-time indexing.
5
min
Substreams.dev
Access tutorials, templates, and documentation to build custom data modules.
5
min
Substreams Pricing
Compare providers and pricing to consume Substreams data.
## /docs/en/supported-networks/megaeth
MegaETH Mainnet
Substreams (Base EVM)
Pinax Network
Type
mainnet
Protocol
ethereum
Identifier
megaeth
Chain ID
eip155:4326
Native Currency
ETH
Indexing Data on MegaETH
MegaETH is a high-performance, EVM-compatible Ethereum Layer 2 built for real-time applications with very high throughput and low latency. The Graph can stream that onchain activity — DEX swaps, pools, and liquidity; lending and borrowing positions; token transfers and holder balances; and contract events — as real-time data with Substreams.
MegaETH is supported by The Graph with Substreams — a parallelized, real-time streaming engine for high-throughput use cases — via
Pinax Network
.
Indexing
MegaETH
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
.
MegaETH
is served with the base EVM block model, so Substreams modules have access to block, transaction, and event (log) 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 covering common onchain data that you can run as-is or compose into your own pipeline. Search for the protocol or data you want on
MegaETH
; 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 an API key from [Pinax Network](https://app.pinax.network/)
.
Scaffold a project with
substreams init
and choose the EVM path, pointing it at your
MegaETH
contract.
Write your extraction and transformation logic in Rust, then run
substreams build
.
Stream the output with
substreams gui
(or
substreams run
) to iterate, then publish your package to the
Substreams Registry
to reuse or share it.
Guides
15
min
Substreams quick start
Stream high-speed data for real-time indexing.
10
min
Substreams.dev
Access tutorials, templates, and documentation to build custom data modules.
8
min
Custom Substreams Sinks
Leverage existing Substreams sinks to access data.
5
min
Substreams starter
Leverage this boilerplate to create your first Substreams module.
7
min
Substreams GitHub repository
Study, contribute to, or customize the core Substreams framework.
## /docs/en/subgraphs/quick-start
Subgraphs
Create, deploy, and query a
Subgraph
on The Graph Network.
By the end, you’ll have:
Initialized a Subgraph from a smart contract
Deployed it to Subgraph Studio for testing
Published to The Graph Network for decentralized indexing using Studio or CLI
Prerequisites
A crypto wallet
A deployed smart contract on a
supported network
Node.js
& a package manager of your choice (
npm
,
yarn
or
pnpm
)
How to Build a Subgraph
1. Create a Subgraph in Subgraph Studio
Go to
Subgraph Studio
Connect your wallet
Click “Create a Subgraph”
Name it in Title Case: “Subgraph Name Chain Name”
2. Install the Graph CLI
On your local machine, run one of the following commands:
Using
npm
:
1
npm install -g @graphprotocol/graph-cli@latest
Using
yarn
:
1
yarn global add @graphprotocol/graph-cli
Verify install:
1
graph --version
3. Initialize your Subgraph
You can find commands for your specific Subgraph in
Subgraph Studio
.
Initialize your Subgraph from an existing contract:
1
graph init
When you initialize your Subgraph, the CLI will ask you for the following information:
Protocol
: Choose the protocol your Subgraph will be indexing data from.
Subgraph slug
: Create a name for your Subgraph. Your Subgraph slug is an identifier for your Subgraph.
Directory
: Choose a directory to create your Subgraph in.
Ethereum network
(optional): You may need to specify which EVM-compatible network your Subgraph will be indexing data from.
Contract address
: Locate the smart contract address you’d like to query data from.
ABI
: If the ABI is not auto-populated, you will need to input it manually as a JSON file.
Start Block
: You should input the start block where the contract was deployed to optimize Subgraph indexing of blockchain data.
Contract Name
: Input the name of your contract.
Index contract events as entities
: It is suggested that you set this to true, as it will automatically add mappings to your Subgraph for every emitted event.
Add another contract
(optional): You can add another contract.
See the following screenshot for an example of what to expect when initializing your Subgraph:
Subgraph command
4. Edit your Subgraph
When making changes to the Subgraph, you will primarily work with three files:
Manifest (
subgraph.yaml
): Defines what data sources your Subgraph will index.
Schema (
schema.graphql
): Defines what data you wish to retrieve from the Subgraph.
AssemblyScript Mappings (
mapping.ts
): Translates data from your data sources to the entities defined in the schema.
For a detailed breakdown on how to write your Subgraph, refer to
Creating a Subgraph
.
Path 1: Studio Approach
5. Build your Subgraph
Run the following:
1
graph codegen && graph build
6. Deploy your Subgraph to Subgraph Studio
When you
deploy
a Subgraph, you push it to
Subgraph Studio
, where you can test, stage and review it. A deployed Subgraph’s indexing is performed by the
Upgrade Indexer
, which is a single Indexer operated by The Graph Foundation. A
deployed
Subgraph is free to use, rate-limited, not visible to the public, and meant to be used for development, staging, and testing purposes.
You do not need to use Subgraph Studio to publish your Subgraph to The Graph Network. Studio is only required for testing and staging your Subgraph prior to publishing.
Get your deploy key from the Subgraph page in Studio
Deploy key
Authenticate:
1
graph auth <DEPLOY_KEY>
Deploy:
1
graph deploy <SUBGRAPH_SLUG>
7. Review in Studio
Use the Studio to:
Run a sample query.
Analyze your Subgraph in the dashboard to check information.
Check the logs on the dashboard to see if there are any errors with your Subgraph. The logs of an operational Subgraph will look like this:
Subgraph logs
8. Publish to The Graph Network
When your Subgraph is ready for a production environment, you can publish it to the decentralized network. Publishing is an onchain action that does the following:
It makes your Subgraph available to be indexed by the decentralized
Indexers
on The Graph Network.
It removes rate limits and makes your Subgraph publicly searchable and queryable in
Graph Explorer
.
It makes your Subgraph available for
Curators
to add curation signal.
Click
Publish
in Studio
Select network
(Recommended) Add curation during the same transaction to save on gas costs:
Subgraph publish
Publish a Subgraph on Subgraph Studio
Curation with 3,000+ GRT is recommended to incentivize indexing.
Path 2: CLI Approach
Open the
graph-cli
.
Run the following commands to build and publish your Subgraph:
graph codegen && graph build
then
graph publish
.
A browser window will prompt you to connect your wallet, add metadata, and publish your Subgraph to the network of your choice.
cli-ui
Custom Options
You can customize the deployment by uploading to a specific IPFS node and using additional flags:
1
USAGE
2
$ graph 프로젝트로 돌아가기