The Graph
The Graph can be added as a plugin to any running network. Once a network is running, please select "Plugins" and install "the Graph". This will create a full Graph node with a Postgres database and IPFS node.
Once the plugin is installed, you will see the following endpoints in the details screen:
- GraphQL Dashboard
- RPC Endpoint
- API Endpoint
- IPFS Endpoint
The API Endpoint supports both REST and Websocket connections. Just replace https
with wss
at the start of the URL.
How to deploy a simple subgraph
The easiest way to deploy a subgraph is with the Graph CLI. You do not need to create an API key as you are using your own Graph node.
First, create a subgraph by running the following command:
graph create <subgraph-name> --node <RPC Endpoint>
Replace <RPC Endpoint>
with the RPC Endpoint that is displayed after you've installed the Graph plugin.
Next, create a new subgraph based on a contract that exists on a public network (e.g. Ethereum Mainnet):
graph init --from-contract <Contract address> --network <network id>
Replace <Contract address>
with the address of the verified contract that you want to index.
Replace <network id>
with the ID of the network as displayed here.
Follow the steps in the CLI:
- Select your network (e.g. Ethereum mainnet)
- Select "Smart contract"
- Give your subgraph a name
- Choose the local directory for your subgraph
- Confirm the contract address
- Choose block height (1 is recommended since Bloctopus networks start block height 1)
- Confirm contract name
- Index contract events as entities
Ensure that your Bloctopus network forks the network where you're retrieving the contract from and make sure that the contract already exists in your network (e.g. by interacting with it).
Finally, you can deploy your subgraph with the following command:
graph deploy --node <RPC Endpoint> --ipfs <IPFS Endpoint> <Subgraph name>
To interact with your subgraph, you can use the RPC Endpoint or navigate to:
<API Endpoint>/subgraphs/name/<subgraph name>
.