Deploy and test your projection
This guide will walk you through deploying your first projection on Datai Network, or for testing purposes on your local machine. Before you start, please make sure you have followed the steps from the previous guide.
Deploying a projection is simple, and Datai CLI will handle most of the heavy lifting.
Let’s start by running the following command
Deploying a projection locally
Before you begin, make sure you have the following prerequisites:
-
Create .env file and make sure you have an archive node for a network of your choice. Please note that you need all of the following environment variables present, even if you don’t have access to particular networks.
-
Make sure you are inside of the dev container.
CTRL + Shift + P
-Dev Containers: Rebuild and Reopen in Container
. Every command you will ever need to run will be from within the container.
This command will deploy both the subgraph and the watcher build into a Docker volume, allowing it to be utilized by the host application.
Deploying watcher and subgraph separately
You can also deploy the watcher and subgraph separately by running the following commands. This is useful in cases where you find errors in one of the components and after fixing them, you’d like to deploy only the fixed part.
Deploying subgraph
Deploying watcher
Run the host application
To ensure the accuracy of positions within your deployment, you can utilize the public host image. Since this image is part of the internal Datai application and provided for testing purposes only, we strongly recommend running it within a Docker Compose environment. This setup will include all necessary environment variables and facilitate communication between internal services.
The host image is already included in the project’s Docker Compose configuration. To start the service, navigate to the root directory of the project and run:
Run the projection indexation
To add a projection for indexation, you can use the following API call to our host application:
In our previous guide, we used Uniswap V2 Liquidity Pool module on Ethereum Mainnet as an example. Here’s how our command would look like:
This will trigger the indexation process for the projection, and you can monitor the progress in the host application logs.
Check status
The indexation process can take some time to complete, depending on the size of the network and the number of positions to be indexed. You can monitor the progress in the host application logs. Here’s how to check the status.
Fetch the data
Once the indexation process is complete, you can fetch the data from the host application. Here’s how to do it.
Replace PROTOCOL
, MODULE
, NETWORK
, and 0x123456789
with the appropriate projection details and user address.
Deploying a projection on Datai Network
Having deployed and tested your projection locally, it is now time to deploy it to Datai Network.
Steps for submission
-
Access the projection dev container: Ensure you are within the projection development environment (the dev container) where the projection has been developed and tested.
-
Submit the Projection: Execute the following command within the dev container to submit the projection data to IPFS:
- TEMPLATE: Replace this with the specific template name used in your projection.
- PROTOCOL: The protocol identifier associated with the projection.
- MODULE: The module name that the projection is part of.
- NETWORK: The network (e.g., mainnet, polygon, arbitrum) where the projection will be deployed.
-
Verify the Submission: After the submission, you should receive a hash that represents the IPFS CID of the projection data.
[deploymentResultsIpfsHash]: The is placeholder will be the actual IPFS CID hash generated upon successful submission to the network.
Stake and Activate the Projection
Using Datai Network Console, you can stake and activate your projection. The process is simple and can be done in a few steps.
- Open the Datai Network Console.
- Navigate to your projections and select the one you’ve just finished developing.
- Using the hash you received after the submission input it in the IPFS hash field.
- Next, stake and confirm your projection registration.
- Confirm the transaction in your wallet and wait for the network confirmation.