Local Deployment Guide
Below is a practical guide on how to spin up your own instance and deploy your contract(s) to a local THORChain environment so you can:
Run a simulated THORChain network locally (Midgard, THORNode, mock L1 chains)
Interact with the chain via CLI and APIs
Build and test contracts with no reliance on external node operators
Setup local environment
If you want to build and run thornode or midgard locally (e.g. for custom tooling or debugging), follow this setup using macOS as an example.
1. Install Required Tools
brew install golang coreutils binutils diffutils findutils gnu-tar gnu-sed gawk grep make git protobuf
2. Update Your PATH (GNU Compatibility)
macOS uses BSD tools by default — THORChain requires GNU tools. Add this to your ~/.zshrc:
# Core GNU tools
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/binutils/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/binutils/lib"
export CPPFLAGS="-I/opt/homebrew/opt/binutils/include"
export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/gawk/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"
# PostgreSQL for Midgard
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/postgresql@16/lib"
export CPPFLAGS="-I/opt/homebrew/opt/postgresql@16/include"
# Go binaries
export GOBIN=$GOPATH/bin
# Reload shell
source ~/.zshrc
3. Verify Your Tools
which gawk && gawk --version
which gsed && gsed --version
These should point to paths under /opt/homebrew/opt/
.
4. Install Docker
Install Docker Desktop: https://www.docker.com/products/docker-desktop/
Make sure it’s running before proceeding.
Setup Localnet
Clone THORNode
git clone https://github.com/thorchain/THORNode.git
cd THORNode
Create deployment on mocknet to spin up a full local, permissioned network to check that all contracts have the permissions they need
make run-mocknet
Start the local mocknet
make start-mocknet
You’ll need to have a local version with wasm_permissions_mocknet containing your permissions
The command spins up: 4 validator nodes, Midgard, L1 mocks (BNB, BTC, ETH)
Access Services
Service
URL
Midgard API
http://localhost:8080/v2
THORNode RPC
http://localhost:1317
ETH RPC (mock)
http://localhost:8545
BNB RPC
http://localhost:26650
Helpful Localnet Commands
Task
Command
Stop the environment
make stop
Rebuild and start clean
make clean start
Tail logs
docker compose logs -f
Restart Midgard only
docker compose restart midgard
Interact with THORNode
Use thornode CLI or curl to API
Example Interactions
Query Midgard:
curl http://localhost:8080/v2/pools
Query THORNode RPC:
curl http://localhost:1317/thorchain/inbound_addresses
Last updated