Setting Up Your Environment
Environment configuration instructions to get started developing on Secret Network.
Secret Contracts are written using the CosmWasm framework. CosmWasm contracts are written in Rust, which is later compiled to WebAssembly (or WASM for short). To write our first Secret Contract, we need to set up a LocalSecret development environment with all the tools required so that you can upload, instantiate, and execute your smart contracts.
LocalSecret is a complete Secret Network testnet and ecosystem containerized with Docker. It simplifies the way secret contract developers test their contracts in a sandbox before they deploy them on a public testnet or mainnet (You can think of it like a local testnet that only you have access to).
There are 3 main tools we will use -
- IDE - a development environment (usually VS Code or JetBrains CLion/IDEA with Rust support)
- SecretCLI - a command-line tool to interact with the blockchain
- LocalSecret - a local Secret Network chain set up for development purposes
We're going to install our environment manually so that you can code in a text editor of your choosing, but if you would prefer to work with JetBrains you can also configure your environment that way using the resources at the bottom of this page.
To follow along with the guide, we will be using
sudo apt-get install git make
brew install make
Note: support for
makeon Windows is limited, so we'll provide separate commands for Windows where necessary
rustup target add wasm32-unknown-unknown
Having Trouble? You might need to restart your terminal, or run a command like:
After installing Rust to configure the current shell
cargo install cargo-generate --features vendored-openssl
SecretCLI is a command-line tool that lets us interact with the Secret Network blockchain. It is used to send and query data as well as manage user keys and wallets.
chmod +x secretcli-Linux
sudo mv secretcli-Linux /usr/local/bin/secretcli
Run the following commands in Powershell to download the latest version of SecretCLI and add it to your profile's PATH:
wget -O "$home/appdata/local/secretcli/secretcli.exe" https://github.com/scrtlabs/SecretNetwork/releases/latest/download/secretcli-Windows
$old_path = [Environment]::GetEnvironmentVariable('path', 'user');
$new_path = $old_path + ';' + "$home\appdata\local\secretcli"
Afterwards, restart the terminal and test the installation with the following command:
An instance of LocalSecret requires approximately 2.5 GB of RAM to run. You may need to increase the resources available in your Docker settings.
The installation methods differ based on the processor architecture. This is because Secret Network makes use of Intel SGX to protect private data.
Now that you have docker installed, open the docker application and then in your terminal run:
ARM (Mac M1)
docker run -it -p 9091:9091 -p 26657:26657 -p 1317:1317 -p 5000:5000 \
--name localsecret ghcr.io/scrtlabs/localsecret:latest
Unfortunately, even LocalSecret inside a docker cannot be run on an M1 Mac. As a workaround, we recommend using a LocalSecret instance in a Gitpod environment.
This environment is set up in such a way that can be accessed remotely as well.
To connect, prepend the port number with the Gitpod URL. e.g., if my workspace is at
https://scrtlabs-gitpoddevenv-shqyv12iyrv.ws-eu54.gitpod.iothen I would be able to connect to the RPC service at
To set up SecretCLI to connect to this environment, use the following commands
secretcli config node https://26657-<your-gitpod-workspace>.gitpod.io
secretcli config chain-id secret-testnet-1
secretcli config keyring-backend test
secretcli config output json
Congrats! You now have a containerized version of LocalSecret running inside docker! You should see blocks being created in real time:
LocalSecret developer testnet
Now it's time to learn how to compile and deploy your first smart contract 🎉
The amazing folks at Digiline created a prebuilt containerized environment containing an IDE (IntelliJ IDEA) that contains everything you need to get started. If you're comfortable with JetBrains IDEs, this may be a good choice for you.
To complement Secret IDE, we will set up another docker container with LocalSecret, where we will deploy our contracts to test and play around with.
docker run -p 8888:8888 -it ghcr.io/digiline-io/secret-ide:0.0.8
Secret IDE has built-in support for both the Pulsar testnet and mainnet, but for the purposes of this guide we will be using the SecretCLI via terminal.
Secret-IDE is also available as a plugin for IDEA, so you can just install it from the marketplace.
Lastly, it will be helpful to configure SecretCLI by using the included "Configure secretcli" command which will set up SecretCLI to target the public testnet
LocalSecret cannot be run on an M1 Mac.
To know whether you have a Mac with an M1 chip or an Intel chip, click on the Apple logo located in the lefthand corner of your desktop and navigate to About This Mac/Overview, and confirm whether the processor is M1 or Intel. If you have an Intel chip, you can run LocalSecret in docker, otherwise, proceed with these set up instructions to learn how to run LocalSecret in Gitpod.
- 2.Gitpod will automatically create a workspace and ask if you want to open it in your text editor. It will then prompt you to allow an extension to open the URI. Select "Open" to proceed.
- 3.If you don't have a registered SSH public key for your computer in your Gitpod account, it will ask you to copy a temporary password to use until you restart the workspace at a later date. Copy the password.
- 4.Enter the password you copied in your text editor to finish setting up the SSH host connection.
- 5.Congrats! You have successfully set up an instance of LocalSecret in Gitpod which you can use for testing your smart contracts.