Skip to content

Run Web3 in Docker

Running blockchain and subgraph nodes locally in Docker might be useful in order to test changes in smart contracts or/and SDKs.

In order to run necessary infra for local web3 - run next command from the project root:

yarn docker:web3-up

This will run hardhat node with HUMAN Protocol smart contracts deployed on it and empty subgraph node w/ its dependencies.

Setting up Subgraph#

First time setup#

Running web3 docker containers for the first time provides you with empty subgraph node. In order to deploy our subgraphs to it you will need to follow next steps:

# Generate subgraph manifest
NETWORK=localhost yarn workspace @tools/subgraph generate
# Create subgraph
yarn workspace @tools/subgraph create-local
# Deploy subgraph
yarn workspace @tools/subgraph deploy-local

After that subgraph is ready for use.

Subsequent launches#

Subgraph containers have Docker volumes attached to it, so every time you stop/start containers - data in subgraph persists, so you don't have to deploy graph again.

In case you make some changes to the subgraph - you might want to either re-deploy it and run re-indexing or have a clean setup. For the latter - remove all existing containers and their volumes:

yarn docker:web3-down

After that run clean web3 services and deploy updated subgraph.

Playing around with local web3#

Our TypeScript SDK has examples folder, where you can find local-node.ts script and use it to play around with your local web3 setup in order to verify that it works as expected:

yarn ts-node example/local-node.ts

Run it multiple times and see if values in KV store are updated.