The Graph 백서

The Graph

원문

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

aphQL. Developers can build, deploy, and publish Subgraphs to The Graph Network. Once it is indexed, the Subgraph can be queried by anyone. Indexer : Network participants that run indexing nodes to index data from blockchains and serve GraphQL queries. Indexer Revenue Streams : Indexers are rewarded in GRT with two components: query fee rebates and indexing rewards. Query Fee Rebates : Payments from Subgraph consumers for serving queries on the network. Indexing Rewards : The rewards that Indexers receive for indexing Subgraphs. Indexing rewards are generated via new issuance of 3% GRT annually. Indexer’s Self-Stake : The amount of GRT that Indexers stake to participate in the decentralized network. The minimum is 100,000 GRT, and there is no upper limit. Delegation Capacity : The maximum amount of GRT an Indexer can accept from Delegators. Indexers can only accept up to 16x their Indexer Self-Stake, and additional delegation results in diluted rewards. For example, if an Indexer has a Self-Stake of 1M GRT, their delegation capacity is 16M. However, Indexers can increase their Delegation Capacity by increasing their Self-Stake. Upgrade Indexer : An Indexer designed to act as a fallback for Subgraph queries not serviced by other Indexers on the network. The upgrade Indexer is not competitive with other Indexers. Delegator : Network participants who own GRT and delegate their GRT to Indexers. This allows Indexers to increase their stake in Subgraphs on the network. In return, Delegators receive a portion of the Indexing Rewards that Indexers receive for processing Subgraphs. Delegation Tax : A 0.5% fee paid by Delegators when they delegate GRT to Indexers. The GRT used to pay the fee is burned. Curator : Network participants that identify high-quality Subgraphs, and signal GRT on them in exchange for curation shares. When Indexers claim query fees on a Subgraph, 10% is distributed to the Curators of that Subgraph. There is a positive correlation between the amount of GRT signaled and the number of Indexers indexing a Subgraph. Curation Tax : A 1% fee paid by Curators when they signal GRT on Subgraphs. The GRT used to pay the fee is burned. Data Consumer : Any application or user that queries a Subgraph. Subgraph Developer : A developer who builds and deploys a Subgraph to The Graph’s decentralized network. Subgraph Manifest : A YAML file that describes the Subgraph’s GraphQL schema, data sources, and other metadata. Here ⁠ is an example. Epoch : A unit of time within the network. Currently, one epoch is 6,646 blocks or approximately 1 day. Allocation : An Indexer can allocate their total GRT stake (including Delegators’ stake) towards Subgraphs that have been published on The Graph’s decentralized network. Allocations can have different statuses: Active : An allocation is considered active when it is created onchain. This is called opening an allocation, and indicates to the network that the Indexer is actively indexing and serving queries for a particular Subgraph. Active allocations accrue indexing rewards proportional to the signal on the Subgraph, and the amount of GRT allocated. Closed : An Indexer may claim the accrued indexing rewards on a given Subgraph by submitting a recent, and valid, Proof of Indexing (POI). This is known as closing an allocation. An allocation must have been open for a minimum of one epoch before it can be closed. The maximum allocation period is 28 epochs. If an Indexer leaves an allocation open beyond 28 epochs, it is known as a stale allocation. When an allocation is in the Closed state, a Fisherman can still open a dispute to challenge an Indexer for serving false data. Subgraph Studio : A powerful dapp for building, deploying, and publishing Subgraphs. Fishermen : A role within The Graph Network held by participants who monitor the accuracy and integrity of data served by Indexers. When a Fisherman identifies a query response or a POI they believe to be incorrect, they can initiate a dispute against the Indexer. If the dispute rules in favor of the Fisherman, the Indexer is slashed by losing 2.5% of their self-stake. Of this amount, 50% is awarded to the Fisherman as a bounty for their vigilance, and the remaining 50% is removed from circulation (burned). This mechanism is designed to encourage Fishermen to help maintain the reliability of the network by ensuring that Indexers are held accountable for the data they provide. Arbitrators : Arbitrators are network participants appointed through a governance process. The role of the Arbitrator is to decide the outcome of indexing and query disputes. Their goal is to maximize the utility and reliability of The Graph Network. Slashing : Indexers can have their self-staked GRT slashed for providing an incorrect POI or for serving inaccurate data. The slashing percentage is a protocol parameter currently set to 2.5% of an Indexer’s self-stake. 50% of the slashed GRT goes to the Fisherman that disputed the inaccurate data or incorrect POI. The other 50% is burned. Indexing Rewards : The rewards that Indexers receive for indexing Subgraphs. Indexing rewards are distributed in GRT. Delegation Rewards : The rewards that Delegators receive for delegating GRT to Indexers. Delegation rewards are distributed in GRT. GRT : The Graph’s work utility token. GRT provides economic incentives to network participants for contributing to the network. Proof of Indexing (POI) : When an Indexer closes their allocation and wants to claim their accrued indexing rewards on a given Subgraph, they must provide a valid and recent POI. Fishermen may dispute the POI provided by an Indexer. A dispute resolved in the Fisherman’s favor will result in slashing of the Indexer. Graph Node : Graph Node is the component that indexes Subgraphs and makes the resulting data available to query via a GraphQL API. As such it is central to the Indexer stack, and correct operation of Graph Node is crucial to running a successful Indexer. Indexer agent : The Indexer agent is part of the Indexer stack. It facilitates the Indexer’s interactions onchain, including registering on the network, managing Subgraph deployments to its Graph Node(s), and managing allocations. The Graph Client : A library for building GraphQL-based dapps in a decentralized way. Graph Explorer : A dapp designed for network participants to explore Subgraphs and interact with the protocol. Graph CLI : A command line interface tool for building and deploying to The Graph. Cooldown Period : The time remaining until an Indexer who changed their delegation parameters can do so again. L2 Transfer Tools : Smart contracts and UI that enable network participants to transfer network related assets from Ethereum mainnet to Arbitrum One. Network participants can transfer delegated GRT, Subgraphs, curation shares, and Indexer’s self-stake. Updating a Subgraph : The process of releasing a new Subgraph version with updates to the Subgraph’s manifest, schema, or mappings. Migrating : The process of curation shares moving from an old version of a Subgraph to a new version of a Subgraph (e.g. when v0.0.1 is updated to v0.0.2). ## /docs/en/supported-networks/mainnet Ethereum Mainnet Subgraphs Subgraph Studio ⁠ • Network Rewards ⁠ Substreams (Extended EVM) The Graph Market ⁠ • Pinax Network ⁠ • Data Nexus ⁠ Type mainnet Protocol ethereum Identifier mainnet Chain ID eip155:1 Native Currency ETH Chain Docs https://ethereum.org/en/developers/docs ⁠ Indexing Data on Ethereum Ethereum is the original programmable, EVM Layer 1 and the largest smart-contract network by developer activity, total value locked, and application diversity, secured by proof-of-stake with ETH 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. Ethereum 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 ⁠ , Pinax Network ⁠ , and Data Nexus ⁠ . Indexing Ethereum 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. Ethereum is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your Ethereum 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 Ethereum takes three steps: Initialize a Subgraph project from your Ethereum 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 Ethereum contract: 1 graph init The CLI walks you through a set of prompts : Protocol : choose ethereum . Ethereum is EVM-compatible. Subgraph slug : an identifier for your Subgraph, for example my-ethereum-subgraph . Directory : where the project is scaffolded. Ethereum network : select mainnet from the list of supported networks. Contract address : the address of the contract you want to index. Find it on etherscan.io . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the Etherscan 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 Ethereum is mainnet . 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 Ethereum : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: mainnet 5 source: 6 address: '0xYourEthereumContractAddress' 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 Ethereum . In your docker-compose.yml , set the Ethereum environment to Ethereum : 1 environment: 2 ethereum: 'mainnet:https://eth.rpc.service.pinax.network' Create and deploy to your local node: 1 graph create --node http://localhost:8020/ my-ethereum-subgraph 2 graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-ethereum-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 Ethereum . 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 Ethereum 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 . Ethereum 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 Ethereum ; 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 Ethereum 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/base Base Chain Subgraphs Subgraph Studio ⁠ • Network Rewards ⁠ Substreams (Extended EVM) The Graph Market ⁠ • Pinax Network ⁠ Type mainnet Protocol ethereum Identifier base Chain ID eip155:8453 Native Currency ETH Chain Docs https://docs.base.org ⁠ Indexing Data on Base Base is an Ethereum Layer 2 built on the OP Stack and part of the Optimism Superchain, incubated by Coinbase, with one of the fastest-growing DeFi, consumer, and onchain-social ecosystems in crypto. 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. Base 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 Base 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. Base is EVM-compatible, so the Subgraph workflow is the same as on most EVM chains. You point a Subgraph at your Base 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 Base takes three steps: Initialize a Subgraph project from your Base 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 Base contract: 1 graph init The CLI walks you through a set of prompts : Protocol : choose ethereum . Base is EVM-compatible. Subgraph slug : an identifier for your Subgraph, for example my-base-subgraph . Directory : where the project is scaffolded. Ethereum network : select base from the list of supported networks. Contract address : the address of the contract you want to index. Find it on base.blockscout.com . ABI : if the CLI cannot fetch the ABI, export it from your build artifacts or the Blockscout 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 Base is base . 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 Base : 1 dataSources: 2 - kind: ethereum 3 name: MyContract 4 network: base 5 source: 6 address: '0xYourBaseContractAddress' 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 Base . In your docker-compose.yml , set the Ethereum environment to Base : 1 environment: 2 ethereum: 'base:https://base.rpc.service.pinax.network' Create and deploy to your local node: 1 graph create --node http://localhost:8020/ my-base-subgraph 2 graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 my-base-subgraph Query the local endpoint until your entities look right, then publish. Step
프로젝트로 돌아가기