The Graph 백서

The Graph

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 18쪽 중 7쪽

n 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 Avalanche . 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 Avalanche 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 . Avalanche 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 Avalanche ; 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 init and choose the EVM path, pointing it at your Avalanche 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/matic Polygon Mainnet Subgraphs Subgraph Studio ⁠ • Network Rewards ⁠ Substreams (Extended EVM) The Graph Market ⁠ • Pinax Network ⁠ Type mainnet Protocol ethereum Identifier matic Chain ID eip155:137 Native Currency POL Chain Docs https://docs.polygon.technology ⁠ Indexing Data on Polygon Polygon PoS is an EVM-compatible, Ethereum-scaling network built for high throughput and near-zero fees. Following the 2025 Rio upgrade it targets thousands of transactions per second with roughly two-second finality and fees of a fraction of a cent, and it settles more stablecoin payment volume than almost any other chain — powering apps like Polymarket alongside a deep DeFi ecosystem (Aave, QuickSwap, Uniswap), gaming, and real-world-asset projects. Its native token is POL. The Graph can index that onchain activity, including DEX swaps, pools, and liquidity; lending and borrowing positions; stablecoin and 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. Polygon 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 ⁠ and Pinax Network ⁠ . Find Existing Subgraphs on Polygon Before you build, check whether the data you need is already live. Many of the most-used protocols on Polygon publish Subgraphs on The Graph that you can query today: Uniswap V3 A concentrated-liquidity DEX for swaps and pools on Polygon. Aave V3 The leading lending and money-market protocol on Polygon. QuickSwap V3 Polygon's leading native decentralized exchange (DEX). Balancer V2 An automated portfolio manager and AMM DEX on Polygon. Polymarket The leading onchain prediction-markets platform on Polygon. DODO A proactive market maker (PMM) DEX for swaps on Polygon. Browse Graph Explorer to search all published Subgraphs on Polygon by protocol, signal, and query volume before deciding to build your own. Indexing Polygon 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. Polygon is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your Polygon 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 Polygon takes three steps: Initialize a Subgraph project from your Polygon 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 Polygon contract: 1 graph init The CLI walks you through a set of prompts : Protocol : choose ethereum . Polygon is EVM-compatible. Subgraph slug : an identifier for your Subgraph, for example my-polygon-subgraph . Directory : where the project is scaffolded. Ethereum network : select matic from the list of supported networks. Contract address : the address of the contract you want to index. Find it on polygonscan.com . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the PolygonScan 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 Polygon is matic . 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 Polygon : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: matic 5 source: 6 address: '0xYourPolygonContractAddress' 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 Polygon . In your docker-compose.yml , set the Ethereum environment to Polygon : 1 environment: 2 ethereum: 'matic:https://polygon.rpc.service.pinax.network' Create and deploy to your local node: 1 graph create --node http://localhost:8020/ my-polygon-subgraph 2 graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-polygon-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 Polygon . 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 Polygon 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 . Polygon 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 Polygon ; 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 init and choose the EVM path, pointing it at your Polygon 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/hyper-evm HyperEVM Mainnet Substreams (Extended EVM) Pinax Network ⁠ Type mainnet Protocol ethereum Identifier hyper-evm Chain ID eip155:999 Native Currency HYPE Chain Docs https://hyperliquid.gitbook.io/hyperliquid-docs/hyperevm ⁠ Indexing Data on HyperEVM HyperEVM is the general-purpose EVM layer of Hyperliquid, the high-performance L1 best known for its onchain perpetuals exchange. It brings EVM smart contracts to the Hyperliquid ecosystem, with native token HYPE and tight integration with HyperCore, Hyperliquid’s order-book and perps layer. 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. HyperEVM is supported by The Graph with Substreams — a parallelized, real-time streaming engine for high-throughput use cases — via Pinax Network ⁠ . Indexing HyperEVM 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 . HyperEVM 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 HyperEVM ; 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 HyperEVM 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/supported-networks/arbitrum-one Arbitrum One Mainnet Subgraphs Subgraph Studio ⁠ • Network Rewards ⁠ Substreams (Extended EVM) The Graph Market ⁠ • Pinax Network ⁠ Type mainnet Protocol ethereum Identifier arbitrum-one Chain ID eip155:42161 Native Currency ETH Chain Docs https://docs.arbitrum.io ⁠ Indexing Data on Arbitrum One Arbitrum One is an Ethereum Layer 2 built by Offchain Labs using optimistic-rollup technology, and one of the largest L2s by total value locked, with a deep DeFi, perps, and gaming ecosystem. 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. Arbitrum One 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 ⁠ and Pinax Network ⁠ . Indexing Arbitrum One 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. Arbitrum One is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your Arbitrum One 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 Arbitrum One takes three steps: Initialize a Subgraph project from your Arbitrum One 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 Arbitrum One contract: 1 graph init The CLI walks you through a set of prompts : Protocol : choose ethereum . Arbitrum One is EVM-compatible. Subgraph slug : an identifier for your Subgraph, for example my-arbitrum-subgraph . Directory : where the project is scaffolded. Ethereum network : select arbitrum-one from the list of supported networks. Contract address : the address of the contract you want to index. Find it on arbiscan.io . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the Arbiscan 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 Arbitrum One is arbitrum-one . 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 Arbitrum One : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: arbitrum-one 5 source: 6 address: '0xYourArbitrumContractAddress' 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 Arbitrum One . In your docker-compose.yml , set the Ethereum environment to Arbitrum One : 1 environment: 2 ethereum: 'arbitrum-one:https://arbone.rpc.service.pinax.network' Create and deploy to your local node: 1 graph create --node http://localhost:8020/ my-arbitrum-subgraph 2 graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-arbitrum-subgraph
프로젝트로 돌아가기