Published in


Dapp development with a local subgraph + Ganache setup

Local subgraph development for time savings and sanity


The are 3 pre-requisites for this tutorial which is for you to have a local Ganache Ethereum blockchain, Docker installed and a subgraph project already initialised for your dapp.

npm install -g ganache-cli

Step 1: Ganache and Required Parameters

With ganache-cli installed, we can spin up a local chain with the following command:

ganache-cli -h
ganache-cli -h -m "MNEMONIC_HERE" -i 5777 
Listening on

Step 2: Running a local Graph node

This bit can be a bit temperamental so bare with it — you may need a few attempts before getting this going.

$ eth_getBlockByNumber

Step 3: Deploying to your local Graph Node

If you’ve deployed a Rinkeby or mainnet subgraph, you’ll know that before deploying, you need to create a project through the dashboard. Locally, you still need to create a project to deploy to and the way in which you do it is via the following command:

yarn create-local
yarn build && yarn deploy-local
  • You will probably already have pre-empted this, but all of your contract addresses in the subgraph.yml file need to match the deployment addresses from the migrations you ran against your local blockchain.


By running a the full Ganache + subgraph stack locally, we open up the ability to iterate much faster thanks to faster local deploys, instant block confirmations etc. However, you can see (and have experienced) that there are a few pain points involved in getting the stack working. We made an attempt at improving the node start up sequence with our bash script, but there are still a number of hoops to jump through to get going. You could automate further by having a script that will spin up a local blockchain, migrate your contracts to that chain, start a graph node etc. and it is something we may consider to help our local development. However, there’s no getting away from the fact that the out of the box solution has it’s quirks and it’s a case of weighing up the time taken to set up the local stack vs maybe deploying to Rinkeby instead. Whatever your thoughts on this are, in general we love the Graph here at BlockRocket and have had more and more clients integrate this into their stack. It’ll be interesting to see how the Dapp stack continues to develop from this point onwards.



Blockchain and decentralised engineering & consultancy based in Manchester, UK — we build products and help companies understand blockchain and web3 technologies. We have vast knowledge in tokensiation, governance, smart contract engineerind, IPFS and crypto

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store