Stagenet Deployment Guide
Prior to diving into stagenet deployment, make sure to follow the Local Deployment Guide.
Below is a practical guide on how to get started deploying to THORChain’s stagenet, taking inspiration from our friends at Nami Protocol who made a similar Devnet Deployment Guide.
It covers the steps from installing and setting up the daemon to connecting to different chain environments, gettings funds on stagenet, and provides a broad overview of Rujira.JS & Rujira.UI.
Install the thornode daemon (macOS)
After
brew install golang coreutils binutils diffutils findutils gnu-tar gnu-sed gawk grep make git protobuf
you need to prioritize the GNU versions and modify your PATH. You’ll find all the commands needed in the installation log of the command before. An example:
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
echo 'export PATH="/opt/homebrew/opt/binutils/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/opt/homebrew/opt/binutils/lib"
export CPPFLAGS="-I/opt/homebrew/opt/binutils/include"
PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/gawk/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"
echo 'export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/opt/homebrew/opt/postgresql@16/lib"
export CPPFLAGS="-I/opt/homebrew/opt/postgresql@16/include"
// reload your shell
source ~/.zshrc
# Verify gawk is available
which gawk
gawk --version
Install Docker: https://www.docker.com/products/docker-desktop/
Add
GOBIN
to yourPATH
.
export GOBIN=$GOPATH/bin
Clone Repo
git clone https://gitlab.com/thorchain/thornode.git
cd thornode
git checkout app/rc1
Install via
make
command
TAG=stagenet make go-generate openapi install
Verify the correct installation
thornode help
Connect to Stagenet
Stagenet is THORChain’s permissionless testnet, allowing you to freely test your contract(s) with real money.
General connection
Connection Details (see details in Developer Endpoints)
Chain-ID: thorchain-stagenet-2
Example commands:
// Query all tokens
thornode query bank total-supply --node https://stagenet-rpc.ninerealms.com/
// Execute a transaction
thornode tx wasm execute <contract-addr> <json-msg> --from <account> --chain-id stage-1 --node https://stagenet-rpc.ninerealms.com/
Deploy a contract using sudo entry points
To deploy a contract on stagenet, test and make sure your sudo entry points work.
Generate the transaction (generate-only):
First, create a basic MsgExecuteContract transaction using the --generate-only flag:
Generate your execute msg only:
Example: thornode tx wasm execute <contract> '<msg>' --from wallet --node https://stagenet-rpc.ninerealms.com --chain-id thorchain-stagenet-2 --generate-only > sudo_tx.json
Update the generated sudo_tx.json:
Change the message type to "/cosmwasm.wasm.v1.MsgSudoContract"
Remove the sender and funds fields
Add the authority field
{
"body": {
"messages": [
{
"@type": "/cosmwasm.wasm.v1.MsgSudoContract",
"authority": "your_wallet",
"contract": "your_contract",
"msg": your_msg
}
}
],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": {
"signer_infos": [],
"fee": {
"amount": [],
"gas_limit": "200000",
"payer": "",
"granter": ""
},
"tip": null
},
"signatures": []
}
Sign the json:
thornode tx sign sudo_tx.json \
--from wallet \
--chain-id thorchain-stagenet-2 \
--node https://stagenet-rpc.ninerealms.com \
--output-document signed_sudo_tx.json
Broadcast tx:
thornode tx broadcast signed_sudo_tx.json \
--node https://stagenet-rpc.ninerealms.com
Store & instantiate a contract
Build and optimize your cosmwasm contract, so you have an artifact. A good starting point is this template: https://github.com/CosmWasm/cw-template/tree/main
Store the contract:
thornode tx wasm store <wasm file> --from <account> --chain-id stage-1 --node https://stagenet-rpc.ninerealms.com/
Instantiate it
thornode tx wasm instantiate <code Id> <InstantiateMsg> --from <account> --chain-id stage-1 --node https://stagenet-rpc.ninerealms.com/
Get assets on stagenet
Assets on stagenet are “real money” so to get assets to test, you will need to deposit real money (e.g. ATOM), swap some of it to another asset (e.g. RUNE) if you need a pair of assets to test, and then send by interacting with the different apps / contracts you want to test.
The easiest way to deposit and swap assets on stagenet is to use preview.rujira.network, which is connected to stagenet:
Deposit: Go to preview.rujira.network/portfolio, connect your wallet (Keplr, Ctrl, Leap or whichever you prefer) and hit the Deposit button. You can find the stagenet thor address (sthor….) in the portfolio page:

Swap: Once you’ve made a deposit, you can swap to e.g. RUNE to get on your sthor address using preview.rujira.network/swap/GAIA.ATOM/THOR.RUNE
If above doesn't work, you can also get RUNE on THORChain via AVAX using below method:
Get RUNE on THORChain Stagenet from AVAX on Avalance
This covers a manual conversion process from AVAX on the Avalance-C chain to RUNE on THORChain Stagenet.
1. Determine the Avalanche inbound address
Go to this URL: https://stagenet-thornode.ninerealms.com/thorchain/inbound_addresses
Find the relevant section, e.g. AVAX:
Find the address field, e.g. 0xd6a6c0b3bb4150a98a379811934e440989209db6
2. Construct the correct message data
Find your deposit address, e.g.: sthor1e2r98hpf3eer8pfpcrsprmrx5vpfq8jpwt06jw
Construct a message using that address of the form: =:THOR.RUNE:sthor1egxvam70a86jafa8gcg3kqfmfax3s0m2ug8gzt
Hex encode that string, e.g.: 3d3a54484f522e52554e453a7374686f723165677876616d37306138366a61666138676367336b71666d6661783373306d32756738677a74
You can use any tool to hex encode data, for example this site: https://www.hexator.com/
And finally, prepend 0x to that string to match MetaMask expectations: 0x3d3a54484f522e52554e453a7374686f723165677876616d37306138366a61666138676367336b71666d6661783373306d32756738677a74
3. Configure MetaMask
You need to ensure that the “show data” option is enabled under advanced settings:
4. Send funds
You can use any Avalanche-compatible wallet, but in this example we're using MetaMask. You need to set message data, which can only be done in the full screen mode. Open MetaMask and choose expand view:
Initiate a send, and configure the destination address, token, and amount, plus the hex data from above:
5. Confirm funds received
Broadcast the transaction above: https://snowtrace.io/tx/0xae863bd2b4407421ec0882d7eada20ba12cffeec8e93f7e77e22b946a952641e
Take that transaction hash to: https://stagenet.thorchain.net/dashboard
Search for that transaction hash, and you’ll find: https://stagenet.thorchain.net/tx/0xae863bd2b4407421ec0882d7eada20ba12cffeec8e93f7e77e22b946a952641e
Last updated