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

Make sure it’s running before proceeding.

Setup Localnet

1. Clone THORNode

git clone https://github.com/thorchain/THORNode.git cd THORNode

2. Create mocknet

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

3. Start mocknet and set permissions

Start the local mocknet and set wasm permission

make start-mocknet

The command spins up: 4 validator nodes, Midgard, L1 mocks (BNB, BTC, ETH)

You’ll need to have a local version with wasm_permissions_mocknet containing your permissions. Set WASMPERMISSIONLESS mimir to 1 to be able to store contracts on the thornode container:

echo password | thornode tx thorchain mimir --keyring-backend file --from thorchain --chain-id thorchain --yes WASMPERMISSIONLESS 1

4. 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