Skip to main content

Environment Setup

In order to start your development journey in Aura, you need to first properly setup your development environment.

Aura is a Cosmos blockchain and it uses CosmWasm, a WebAssembly smart contract platform (or module) that integrate natively with Cosmos SDK. Smart contracts are written in RUST, compiled into Wasm then uploaded to the Aura chain.

In this section

You will follow the process for setting up your development environment to build on Aura Network, learn about CosmWasm and getting started on an Aura testnet so you can get familiar with it.

Intro to CosmWasm

CosmWasm is a developer-friendly smart contract runtime designed for Cosmos blockchains. It provides a secure and efficient environment for executing smart contracts written in the Rust programming language.

What is CosmWasm?

CosmWasm brings the power of WebAssembly (Wasm) to the Cosmos ecosystem. It enables developers to write smart contracts in Rust, a highly performant systems programming language, and compile them into WebAssembly bytecode. These smart contracts can then be executed in a secure sandbox environment, ensuring the integrity and safety of the blockchain network.

Why use CosmWasm?

There are several compelling reasons to choose CosmWasm for your smart contract development on Cosmos-based blockchains:

  1. Security: CosmWasm leverages the Rust programming language, known for its memory safety and strong type system. By utilizing Rust, CosmWasm smart contracts are less prone to vulnerabilities like memory leaks, buffer overflows, and null pointer dereferences like you would find on other blockchains.

  2. Performance: Rust's low-level control and minimal runtime overhead make CosmWasm smart contracts highly efficient and performant. This is particularly crucial for blockchain applications where speed and scalability are vital.

  3. Interoperability: CosmWasm contracts are designed to be compatible with various Cosmos SDK-based blockchains. Once deployed, a CosmWasm contract can be easily reused across different networks, promoting interoperability and code reusability.

  4. Developer-Friendly: With a rich ecosystem and tooling support, CosmWasm offers developers a familiar and productive environment. The Rust programming language has a vibrant community, excellent documentation, and a powerful package manager (Cargo), making it easier to build, test, and maintain complex smart contracts.

You can also learn more about CosmWasm in the official Cosmwasm document.

Prerequisites

To develop any smart contract, you will need to install Node.js. If you want to use Rust as your main language, you also need to install rustup.

Node.js

Download and install Node.js. We suggest you use NVM (Node Version Manager), which is a great utility that allows you to quickly install and run different versions of Node according to your requirements via the command line. You can install it with the following command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

Using NVM is fairly straightforward, here are some example usages:

$ nvm use 16
Now using node v16.9.1 (npm v7.21.1)
$ node -v
v16.9.1
$ nvm use 14
Now using node v14.18.0 (npm v6.14.15)
$ node -v
v14.18.0
$ nvm install 12
Now using node v12.22.6 (npm v6.14.5)
$ node -v
v12.22.6

Alternatively, you can also use Yarn to install and manage node-module packages:

npm install -g yarn

Go

Aura requires a Go version newer than 1.18. You can use GVM (Golang Version Manager) to manage all Go versions on your machine. To install, run the following command:

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

Install Go using GVM

After you've installed GVM, you can easily install go by running this:

gvm install go1.18.7 -B
gvm use go1.18.7

Once this is done, Go will be in your PATH and ready to use. $GOROOT and $GOPATH are set automatically.

You can check the current version of Go using:

go version

Rust

To build in Aura, you will need to use Rust. We recommend you install it through Rustup. If you want to see a more detailed guide, you can check out the Rust getting started page.

Install Rust

Download Rustup and run it to install Rust using the command below, then just follow the on-screen instructions.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Configuring the PATH environment variable

All Rust tools are installed to the ~/.cargo/bin directory. There you will find the rustc, cargo and rustup binaries. To add them to your PATH, open in your desired editor and add the directory to it.

sudo nano ~/.profile

Add to the end of ~/.bashrc the following line:

export PATH="$HOME/.cargo/bin:$PATH"

Then save it and check the current cargo version and update rustup:

rustup default stable
cargo version
# If this is lower than 1.55.0, update
rustup update stable

You also need to install cargo-generate and cargo-run-script. You can do so with the following commands:

cargo install cargo-generate --features vendored-openssl
cargo install cargo-run-script

Wasm

Wasm (wasmd) is the backbone of the CosmWasm platform. It is the implementation of a Cosmos zone with wasm smart contracts enabled.

Install the wasm32 target

# Check the target toolchains of rustup
rustup target list --installed
# Add the wasm toolchain
rustup target add wasm32-unknown-unknown

Docker

Docker is an open platform for developing, shipping, and running applications. You can download it in the Official Docker Website.

Beaker tools

Beaker is a tool used to scaffold new cosmwasm apps, with all of the dependencies for osmosis hooked up, interactive console, and a sample front-end ready to use. You can install through cargo which is a Rust toolchain.

cargo install -f beaker # `-f` flag for up-to-date version

Command-line tools

We will be using a few command-line tools extensively, you can install them with this command:

apt install jq curl

Install Aura CLI

The aurad binary is the official client for Aura Network. To install it, you need to clone the aura repo:

git clone [email protected]:aura-nw/aura.git

And install it using makefile:

cd aura
make

The aurad bin file will be located in ${source_directory}/build/ or GO_PATH (default ~/go/bin/).

Note:

  1. The blockchain full-node presents itself as a binary, generally suffixed by -d for "daemon" (e.g. aurad for aura).
  2. In case of using aurad bin file on ${source_directory}/build/, you need to add it to your PATH environment variable. You can do this by adding the following line to your ~/.profile file or running it directly in your terminal:
export PATH=$PATH:${source_directory}/build
  1. In case of using aurad bin file on GO_PATH, you need to add it to your PATH environment variable. You can do this by adding the following line to your ~/.profile file or running it directly in your terminal:
export PATH=$PATH:~/go/bin
tip

You can specify the RPC Port and directory of block data amongst other configurations in the config.toml file located in $HOME/.aura/config.

Using Aura CLI with a public node

For development and test purposes, it's easier to use a public RPC node than to run your own. You can setup aurad to use a public node easily.

You can use the official Aura public nodes or any third-party nodes for this. You can view all of the available RPC endpoints as well as LCD or gRPC on the Networks Information section.

Once you select your desired network and node, go into ~/.aura/config/client.toml and set the node to your selected endpoint, and chain-id for the network.

# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml

###############################################################################
### Client Configuration ###
###############################################################################

# The network chain ID
chain-id = "aura_6322-2"
# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory)
keyring-backend = "test"
# CLI output format (text|json)
output = "text"
# <host>:<port> to Tendermint RPC interface for this chain
node = "https://rpc.aura.network:443"
# Transaction broadcasting mode (sync|async|block)
broadcast-mode = "sync"

caution

On the example above, the keyring-backend is set to test to avoid having to enter your password evert time your keys on your OS. Do not use this configuration on a development environment.

Once you've done that, you can create a key to use by running:

aurad keys add <key-name>

You can get that key's public address by running

aurad keys show <key-name> -a

You will need some test aura coins (eaura in Euphoria). We have easy to use faucets for both Euphoria and Serenity in our Discord. Check out the instructions in the faucets section.

Once you have some balance, you can verify it with aurad by running:

aurad query bank balances <public-address>

Faucets

You can quickly and easily get some test coins in our Discord in the #faucet channels we have by sending I love Aura <public-address> and you'll promptly receive 2 EAURA for Euphoria or AURA for Serenity. Below are the direct links to the channels.

Happy hacking!