🚀

Deploy Uniswap-V2 Subgraph on Mainnet

Uniswap v2 Subgraph Deployment Recipe

To deploy the Uniswap v2 subgraph on 0xgraph and integrate it into your decentralized application, follow the step-by-step instructions provided below: Note: Note: Before proceeding, ensure that you have Node.js installed on your system.

Install the latest version of Node.js

  • Open a terminal or command prompt.
  • Install the latest version of Node.js by visiting the official Node.js website (https://nodejs.org) and following the installation instructions specific to your operating system.

Install the 0xgraph CLI

See Section The 0xgraph CLI

Clone the Uniswap v2 subgraph repository

Run
git clone https://github.com/Uniswap/v2-subgraph.git
to clone the Uniswap v2 subgraph repository to your local machine.

Install dependencies

  • Navigate to the cloned directory: cd v2-subgraph.
  • Execute npm install to install the required dependencies for the subgraph.

Generate subgraph types

Run the command to generate subgraph types:
0xgraph codegen --output-dir src/types/

Build the subgraph

Execute the following command to build the subgraph:
0xgraph build

Create and deploy the subgraph

Run the following command to create a subgraph with the specified name:
0xgraph create uniswap-v2-mainnet/v0.1
Next, execute the following command to deploy your Uniswap subgraph
0xgraph deploy uniswap-v2-mainnet/v0.1
If the deployment is successful, you will receive a completion message with the deployment ID. An example completion message may appear as follows:
"Build completed: Qmch3jVuuUYZ6iipxz3fUVo2zZocJkbjCVVtkbbwyZ6svr".

View deployed subgraphs

To view the urls of all your deployed subgraphs you may view it in your account:
Deployed subgraphs
Alternatively, you may use the CLI to list all your subgraphs:
0xgraph subgraph list
Congratulations! 🚀🚀🚀 You have now successfully deployed the Uniswap v2 subgraph. You can utilize the provided deployment ID to query the subgraph or integrate it into your decentralized application, enabling seamless access to Uniswap v2 data.
Last modified 7mo ago