¿Qué es el Servicio Alojado?
Reading time: 3 min
Please note, hosted service endpoints will no longer be available after June 12th 2024 as all subgraphs will need to upgrade to The Graph Network. Please read more in the
This section will walk you through deploying a subgraph to the .
If you don't have an account on the hosted service, you can sign up with your GitHub account. Once you authenticate, you can start creating subgraphs through the UI and deploying them from your terminal. The hosted service supports a number of networks, such as Polygon, Gnosis Chain, BNB Chain, Optimism, Arbitrum, and more.
Para una lista completa, consulta .
First follow the instructions to install the Graph CLI. Create a subgraph by passing in graph init --product hosted-service
If you already have a smart contract deployed to your network of choice, bootstrapping a new subgraph from this contract can be a good way to get started on the hosted service.
You can use this command to create a subgraph that indexes all events from an existing contract. This will attempt to fetch the contract ABI from the block explorer.
graph init \--product hosted-service--from-contract <CONTRACT_ADDRESS> \<GITHUB_USER>/<SUBGRAPH_NAME> [<DIRECTORY>]
Additionally, you can use the following optional arguments. If the ABI cannot be fetched from the block explorer, it falls back to requesting a local file path. If any optional arguments are missing from the command, it takes you through an interactive form.
--network <ETHEREUM_NETWORK> \--abi <FILE> \
El <GITHUB_USER>
en este caso es tu nombre de usuario u organización de GitHub, <SUBGRAPH_NAME>
es el nombre de tu subgrafo y <DIRECTORY>
es el nombre opcional del directorio donde el graph init colocará el manifiesto del subgrafo de ejemplo. El <CONTRACT_ADDRESS>
es la dirección de tu contrato existente. <ETHEREUM_NETWORK>
es el nombre de la red Ethereum en la que vive el contrato. <FILE>
es una ruta local a un archivo ABI de contrato. Tanto --la red como --abi son opcionales.
El segundo modo que admite graph init
es la creación de un nuevo proyecto a partir de un subgrafo de ejemplo. El siguiente comando lo hace:
graph init --from-example --product hosted-service <GITHUB_USER>/<SUBGRAPH_NAME> [<DIRECTORY>]
El subgrafo de ejemplo se basa en el contrato Gravity de Dani Grant que administra los avatares de los usuarios y emite eventos UpdateGravatar
o UpdateGravatar
cada vez que se crean o actualizan avatares. El subgrafo maneja estos eventos escribiendo entidades Gravatar
en el almacén de Graph Node y asegurándose de que se actualicen de acuerdo con los eventos. Continúa con el para comprender mejor a qué eventos de sus contratos inteligentes debe prestar atención, mappings y más.
To build a subgraph tailored for monitoring a Proxy contract, initialize the subgraph by specifying the address of the implementation contract. Once the initialization process is concluded, the last step involves updating the network name in the subgraph.yaml file to the address of the Proxy contract. You can use the command below.
graph init \--product hosted-service--from-contract <IMPLEMENTATION_ADDRESS> \<GITHUB_USER>/<SUBGRAPH_NAME> [<DIRECTORY>]