Deploy Ocean Subgraph
About Ocean Subgraph
Ocean subgraph allows querying the datatoken, data NFT, and all event information using GraphQL. Hosting the Ocean subgraph saves the cost and time required in querying the data directly from the blockchain. The steps in this tutorial will explain how to host Ocean subgraph for the EVM-compatible chains supported by Ocean Protocol.
Ocean Subgraph is deployed on top of graph-node, therefore, in this document, we will show first how to deploy graph-node - either using Docker Engine or Kubernetes - and then how to install Ocean Subgraph on the graph-node system.
Deploying Graph-node using Docker Engine and Docker Compose
Prerequisites
A server for hosting Graph-node. See this guide for how to create a server;
Docker Compose and Docker Engine are installed and configured on the server. See this guide for how to install these products.
The RPC URLs and API keys for each of the networks to which Ocean Subgraph will be connected. See this guide for how to obtain the URL and the API key.
Steps
1. Create the /etc/docker/compose/graph-node/docker-compose.yml file
From a terminal console, create the /etc/docker/compose/graph-node/docker-compose.yml file, then copy and paste the following content to it (. Check the comments in the file and replace the fields with the specific values of your implementation.
/etc/docker/compose/graph-node/docker-compose.yml (annotated - example for sepolia network)
2. Create the /etc/systemd/system/[email protected] file
Create the /etc/systemd/system/[email protected] file then copy and paste the following content to it. This example file could be customized if needed.
3. Reload the systemd manager configuration
Run the following command to reload the systemd manager configuration
Optionally, you can enable the services to start at boot, using the following command:
4. Start graph-node service
To start the Ocean Subgraph service, run the following command:
5. Check the service's status
Check the status of the service by running the following command. The output of the command should be similar to the one presented here.
6. Check graph-node service logs
If needed, use docker CLI to check Ocean Subgraph service logs.
First, check the container status
Then, check the logs of the Ocean Subgraph docker container:
Deploying graph-node using Kubernetes
In this example, we will deploy graph-node as a Kubernetes deployment service. graph-node has the following dependencies: PostgreSQL and IPFS.
Prerequisites:
A server for hosting graph-node. See this guide for how to create a server;
Kubernetes with Docker Engine is installed and configured on the server. See this chapter for information on installing Kubernetes.
The RPC URLs and API keys for each of the networks to which the Provider will be connected. See this guide for how to obtain the URL and the API key.
Steps
1. Deploy PostgreSQL
It is recommended to deploy PostgreSQL as helm chart.
References: https://github.com/bitnami/charts/tree/main/bitnami/postgresql/#installing-the-chart
Once PostgreSQL pods are running, a database must be created: eg. sepolia.
2. Deploy IPFS
The following template can be customized to deploy IPFS statefulset and service.
Deploy Graph-node
The following annotated templated can be customized to deploy graph-node deployment and service:
Deploy Ocean Subgraph
After you deployed graph-node, either using Kubernetes or Docker Compose, you can proceed to deploy Ocean Subgraph on top of it.
Prerequisites
graph-node up-and-running
Steps
1. Install Node.js locally
To install Node.js locally, please refer to this link for instructions.
2. Download and extract Ocean-subgraph
Download and extract Ocean-subgraph (check here the available releases).
3. Install dependencies
From the directory where Ocean subgraph was extracted, run the following command:
4. Deploy Ocean Subgraph
In the following example, we are deploying on Ocean Subgraph on graph-node running for sepolia testnet.
Note: for ocean-subgraph deployment in the Kubernetes environment, both graph-node and ipfs services must be locally forwarded using kubectl port-forward command.
Run the following command:
Ocean Subgraph is deployed under /subgraphs/name/oceanprotocol/ocean-subgraph/. To access it from the server on which it was deployed, open a browser and go to http://127.0.0.1:8000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql.
Last updated
Was this helpful?

