Step-by-Step System Setup for CosmWasm Smart Contract Developers
Get ready to develop CosmWasm smart contracts 🤩
Hello there!
You are interested in joining the Cosmos Ecosystem and develop CosmWasm smart contracts but you don’t know where to start. I have been there.
Don’t worry, I got you covered.
In this guide you will learn how to set up your computer so you can develop CosmWasm smart contracts. I will cut through the noise and keep it short. Let’s go.
Install Golang
Go is used to build CLI daemon tools such as wasmd, terrad, junod et al. You need to install v1.18+
. There are multiple ways to install Go, I will just link to the most popular ones:
Download Go from the official website (OS independent)
Via brew (Mac users)
Via apt (Linux users)
Install Rust 🦀
If you are on Linux or Mac, Go to https://rustup.rs/ and run the command displayed there on your terminal.
Now, run the following commands:
rustup default stable
cargo version
# If this is lower than 1.55.0+, update
rustup update stable
rustup target list --installed
rustup target add wasm32-unknown-unknown
It is critical that you add the wasm32-unknown-unknown
target otherwise you won’t be able to compile smart contracts.
If you are a Windows user, you need to download an executable file found here. It might happen that you are requested to install Visual C++ Build Tools. If so, do it from https://visualstudio.microsoft.com/visual-cpp-build-tools/ and make sure "Windows 10 SDK" and "English language pack" are selected.
For detailed information and optional steps, check out the CosmWasm Docs.
Important command-line tools
The following tools are not mandatory but you kind of need them if you want to make your life as a developer easy. These are some of the tools I personally use:
jq → json processor
curl → download files from the internet
git → version control (this one is actually mandatory if you wanna make it)
docker → for using docker images. This will be relevant when compiling contracts to be deployed on a blockchain (mandatory)
grep → file pattern searcher
sed / awk → stream editors and text processing tools used for filtering and transforming text data
Figure out how to install those. If you are on Linux or Mac, most of them should probably be already installed out of the box.
Install an IDE
The IDE is the software that allows you to write code, where you are gonna develop the smart contracts. If you are a programmer you already know this but still it’s worth mentioning it.
Here are few options for you to choose from:
Intellij IDEA → My favorite, it’s powerful. The community (free) edition works fine. Download it here.
VS Code → Good editor, lightweight. Grab it here.
Zed → high-performance rust-based editor. Haven’t tried it enough myself to give an opinion, but I like what I see. It’s blazing fast, reminds me of sublime’s performance if not faster. Download it here.
Vim → if you use vim, you probably don’t need my guidance on this. Just get the rust plugin for it and you are ready to go.
There’s also the CosmWasm IDE extension, but I personally don’t like it much and also it’s for VS code, which I don’t use. Here it is.
Setup a local blockchain environment
This is actually a separate guide in itself, a topic for another day. For now, know that you will need to install a daemon to either run a local blockchain or connect to a real one, whether it is a testnet or mainnet.
Which one to download really depends on what chain you are gonna build on, as each has different binaries 🤦♂️. Here are some of the most popular ones, in no particular order:
If you already know which chain you are gonna develop on, go ahead and download the binary for that. Otherwise stick with me for another guide where I will walk you through the process.
Will be making a video on this soon, stay tuned.
What’s next?
Unless you are an experience rust developer, go do the rustlings 🦀❤️. They are a series of challenges that teach you rust by solving them.
Now, you are ready to write your first cosmwasm smart contract.
Happy coding!