What is the Hosted Service?
Please note, the Hosted Service is sunsetting in Q1 2023, but it will remain available until that time. All developers are strongly encouraged to migrate their subgraphs to the decentralized network. Read more about the sunsetting of the Hosted Service here.
This section will walk you through deploying a subgraph to the Hosted Service.
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. Graph Node supports a number of Ethereum testnets (Rinkeby, Ropsten, Kovan) in addition to mainnet.
First follow the instructions here 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 Ethereum mainnet or one of the testnets, 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 Etherscan.
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 Etherscan, 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> \
<GITHUB_USER> in this case is your GitHub user or organization name,
<SUBGRAPH_NAME> is the name for your subgraph, and
<DIRECTORY> is the optional name of the directory where graph init will put the example subgraph manifest. The
<CONTRACT_ADDRESS> is the address of your existing contract.
<ETHEREUM_NETWORK> is the name of the Ethereum network that the contract lives on.
<FILE> is a local path to a contract ABI file. Both --network and --abi are optional.
The second mode
graph init supports is creating a new project from an example subgraph. The following command does this:
graph init --from-example --product hosted-service <GITHUB_USER>/<SUBGRAPH_NAME> [<DIRECTORY>]
The example subgraph is based on the Gravity contract by Dani Grant that manages user avatars and emits
UpdateGravatar events whenever avatars are created or updated. The subgraph handles these events by writing
Gravatar entities to the Graph Node store and ensuring these are updated according to the events. Continue on to the subgraph manifest to better understand which events from your smart contracts to pay attention to, mappings, and more.
You can find the list of the supported networks Here.