The Graph 백서

The Graph

원문

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

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 Base . 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 Base 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 . Base 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 Base ; 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 Base 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/bsc BNB Smart Chain Mainnet Subgraphs Subgraph Studio ⁠ • Network Rewards ⁠ Substreams (Extended EVM) The Graph Market ⁠ • Pinax Network ⁠ Type mainnet Protocol ethereum Identifier bsc Chain ID eip155:56 Native Currency BNB Chain Docs https://docs.bnbchain.org ⁠ Indexing Data on BNB Smart Chain BNB Smart Chain (BSC) is a high-performance, EVM-compatible Layer 1 that has run in production since September 2020, with sub-second block times and transaction fees of a fraction of a cent. It hosts one of the largest DeFi ecosystems in crypto — tens of billions of dollars in total value locked across protocols like PancakeSwap (DEX), Venus (lending), and 1,500+ live dApps spanning trading, gaming, and payments. 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. BSC 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 BNB Smart Chain Before you build, check whether the data you need is already live. Many of the most-used protocols on BSC publish Subgraphs on The Graph that you can query today: Uniswap V4 The newest generation of the Uniswap DEX on BSC. Uniswap V3 A concentrated-liquidity DEX for swaps and pools on BSC. PancakeSwap V3 The largest decentralized exchange on BSC. Aave V3 A top cross-chain lending and money-market protocol. Venus The largest BSC-native lending and money-market protocol. DODO A proactive market maker (PMM) DEX for swaps on BSC. Browse Graph Explorer to search all published Subgraphs on BSC by protocol, signal, and query volume before deciding to build your own. Indexing BNB Smart Chain 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. BSC is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your BSC 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 BSC takes three steps: Initialize a Subgraph project from your BSC 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 BSC contract: 1 graph init The CLI walks you through a set of prompts : Protocol : choose ethereum . BSC is EVM-compatible. Subgraph slug : an identifier for your Subgraph, for example my-bsc-subgraph . Directory : where the project is scaffolded. Ethereum network : select bsc from the list of supported networks. Contract address : the address of the contract you want to index. Find it on bscscan.com . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the BscScan 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 BSC is bsc . 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 BSC : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: bsc 5 source: 6 address: '0xYourBscContractAddress' 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 BSC . In your docker-compose.yml , set the Ethereum environment to BSC : 1 environment: 2 ethereum: 'bsc:https://bsc.rpc.service.pinax.network' Create and deploy to your local node: 1 graph create --node http://localhost:8020/ my-bsc-subgraph 2 graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-bsc-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 BSC . 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 BNB Smart Chain 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 . BSC 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 BSC ; 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 BSC 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/solana-mainnet-beta Solana Mainnet Substreams (Non-EVM) The Graph Market ⁠ • Pinax Network ⁠ Type mainnet Identifier solana-mainnet-beta Chain ID solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp Native Currency SOL Chain Docs https://solana.com/docs ⁠ Indexing Data on Solana Solana is a high-throughput Layer 1 known for fast, low-cost transactions and a large DeFi, NFT, and payments ecosystem. The Graph can stream that onchain activity — program interactions, DEX swaps, token transfers and balances, and account updates — as real-time data with Substreams. Solana is supported by The Graph with Substreams — a parallelized, real-time streaming engine for high-throughput use cases — via The Graph Market ⁠ and Pinax Network ⁠ . Indexing Solana 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 . Solana is available through Substreams’ Solana block model, so modules have access to blocks, transactions, and instructions. 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 Solana; 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 ⁠ (no personal information required). Scaffold a project with substreams init and choose the Solana path. 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/avalanche Avalanche C-Chain Subgraphs Subgraph Studio ⁠ • Network Rewards ⁠ Substreams (Base EVM) The Graph Market ⁠ • Pinax Network ⁠ Type mainnet Protocol ethereum Identifier avalanche Chain ID eip155:43114 Native Currency AVAX Chain Docs https://docs.avax.network ⁠ Indexing Data on Avalanche Avalanche C-Chain is the EVM-compatible contract chain of the Avalanche network, a high-throughput Layer 1 with sub-second finality and a broad DeFi, gaming, and institutional ecosystem, with AVAX 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. Avalanche 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 Avalanche 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. Avalanche is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your Avalanche 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 Avalanche takes three steps: Initialize a Subgraph project from your Avalanche 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 Avalanche contract: 1 graph init The CLI walks you through a set of prompts : Protocol : choose ethereum . Avalanche is EVM-compatible. Subgraph slug : an identifier for your Subgraph, for example my-avalanche-subgraph . Directory : where the project is scaffolded. Ethereum network : select avalanche from the list of supported networks. Contract address : the address of the contract you want to index. Find it on snowtrace.io . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the Snowtrace 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 Avalanche is avalanche . 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 Avalanche : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: avalanche 5 source: 6 address: '0xYourAvalancheContractAddress' 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 Avalanche . In your docker-compose.yml , set the Ethereum environment to Avalanche : 1 environment: 2 ethereum: 'avalanche:https://avalanche.rpc.service.pinax.network' Create and deploy to your local node: 1 graph create --node http://localhost:8020/ my-avalanche-subgraph 2 graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-avalanche-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 i
프로젝트로 돌아가기