A few days ago, I got stuck trying to install Graph-cli on my Ubuntu operating system. I had to make a lot of research to figure it out, and I did with the help of my peers too.
In this article, I will be sharing how to install Graph-cli on Ubuntu, and this will be a quick one.
For Ubuntu, install with yarn or npm:
sudo yarn global add @graphprotocol/graph-cli
The sudo keyword gives the dependencies root access to your OS
Other Methods on Linux
libsecret is used for storing access tokens, so you may need to install it before getting started. Use one of the following commands, depending on your distribution:
sudo apt-get install libsecret-1-dev
sudo yum install libsecret-devel
sudo pacman -S libsecret
For other OS, install with yarn or npm:
yarn global add @graphprotocol/graph-cli
Once installed, the graph init command can be used to set up a new subgraph project, either from an existing contract on any of the public Ethereum networks or from an example subgraph. This command can be used to create a subgraph on the Subgraph Studio by passing in graph init --product subgraph-studio.
If you already have a smart contract deployed to the Ethereum mainnet or one of the testnets, bootstrapping a new subgraph from that contract can be a good way to get started.
Learn more about creating and deploying subgraph here.