Installation
In this section, we will gear up your workhorse for developing, deploying and, enjoying smart contracts on Tgrade network.
#
GoYou can setup golang following official documentation. The latest
versions of wasmd
require go version v1.15
.
#
RustAssuming you have never worked with rust, you will first need to install some tooling. The standard approach is to
use rustup
to maintain dependencies and handle updating multiple versions of
cargo
and rustc
, which you will be using.
#
Installing Rust in Linux and MacFirst, install rustup. Once installed, make sure you have the wasm32 target:
rustup default stablecargo versionrustup update stable
rustup target list --installedrustup target add wasm32-unknown-unknown
#
Installing Rust in Windows 10First, download and execute rustup-init.exe
from rustup.rs
or rust-lang.org.
If requested, manually download and install Visual C++ Build Tools 2019, from https://visualstudio.microsoft.com/visual-cpp-build-tools/ . Make sure "Windows 10 SDK" and "English language pack" are selected.
Continue running rustup-init.exe
, and proceed with the installation.
Optionally:
- Download and install gvim, and modify the Env vars to add \<gvim folder> to the PATH.
- Download and install git for windows. Modify the Env vars to add \<git folder>\bin to PATH.
- Turn on Developer Mode (Settings -> Update and Security: For Developers) and enable Device Discovery, to be able to access the Windows 10 server through ssh (https://www.ctrl.blog/entry/how-to-win10-ssh-service.html#section-mssshserv-enable).
Install the wasm32 target:
rustup default stablecargo versionrustup update stable
rustup target list --installedrustup target add wasm32-unknown-unknown
#
wasmdwasmd
is the backbone of CosmWasm platform. It is both blockchain node and interaction client.
It is the implementation of a Cosmos zone with wasm smart contracts enabled.
tgrade
binary that will be released is a modified version of wasmd
. For deployment and interaction, we will
use wasmd
for now.
warning
ARM architecture is not supported at the moment. You can deploy contracts on GitPod or an Ubuntu remote machine
git clone https://github.com/CosmWasm/wasmd.gitcd wasmd# replace the v0.18.0 with the most stable version on https://github.com/CosmWasm/wasmd/releasesgit checkout v0.18.0make install
go install -mod=readonly \ -ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=tgrade -X github.com/CosmWasm/wasmd/app.Bech32Prefix=tgrade" \ ./cmd/wasmd
# verify the installationwasmd version
info
If you have any problems here, check your PATH
. make install
will copy wasmd
to
$HOME/go/bin
by default, please make sure that is set up in your PATH
as well, which should be the case in general
for building Go code from source.
#
Setting up your IDEWe will need a good editor to guide us through the experience. We highly recommend plugins that help you learn syntax, especially when just starting rust. There are two free editor environments we recommend, choose the one that is more familiar to you.
If you use VSCode (Download link) you just need to add the rust plugin. This is the best supported environment for RLS (Rust Language Server) and uses the rust compiler to type-check all your code on save. This gives the same error messages as the actual compiler would and highlights along the line of the code, but it can be a bit slow to respond sometime (as it runs the compiler). It is quite good, and if you are used to VSCode, I highly recommend it:
The other option I can recommend it Intellij IDEA Community Edition (Download link), along with the Rust Plugin. This has very nice and quick support for many language features directly inline. In particular, it shows the inferred types along variables, which can be very helpful, especially when working with (nested) generics. It catches most syntax errors very quickly, but not all of them. Which means sometimes you have to look at the compile failures to find the errors. If you are coming from another Intellij product (eg. Goland), I recommend this approach:
There are many more editors out there and some have varying degrees of rust support, at least syntax highlighting, but I would recommend trying one of the two above, especially if you are new to rust. Once you are confident in the language, you can always use another editor and customize it to your liking.