Installing required tools

Before running your first smart contract on Aleph Zero, you will first need to prepare your computer for development in Rust and ink!. Here's a handy guide to get you started.

The first thing you need to do before you can deploy your first smart contract on the Aleph Zero Testnet is to prepare your computer for development in Rust and ink!.

Rust

This guide uses https://rustup.rs installer and the rustup tool to manage the Rust toolchain. It's the default way of installing Rust and we highly recommend doing it that way. However, if you prefer a different method, please check the "Other installation methods" section on the official Rust website.

To install and configure rustup enter the following commands in your shell:

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

Now you have the latest stable version of Rust installed on your computer. For the development of smart contracts you will need a slightly more recent nightly version, together with some additional components:

rustup toolchain install nightly
rustup component add rust-src --toolchain nightly
rustup target add wasm32-unknown-unknown --toolchain nightly

Rust comes with its native package manager cargo which is also used for compiling Rust code. Make sure cargo is installed correctly and visible in your shell environment:

cargo --help

ink!

ink! is an Embedded Domain Specific Language (EDSL) that can be used to write WASM smart contracts in Rust. In other words, ink! is a collection of "add-ons" on top of Rust that modify the behavior of the language to produce, instead of regular binary code that can be executed by your computer, special WASM code compatible with Substrate-based smart contracts execution environment. Ultimately, every ink! smart contract is just a normal Rust program with a tiny bit of additional ink!-specific headers called "macros".

To start using ink! you first need to install the binaryen package, which is used to optimize the WebAssembly bytecode of the contract. Most likely binaryen is available from your default package manager:

# For Ubuntu or Debian users:
sudo apt install binaryen
# For MacOS users:
brew install binaryen
# For Arch or Manjaro users:
pacman -S binaryen

You can also directly download a binary release.

With binaryen present you can install cargo contract:

cargo install --force --locked cargo-contract

cargo contract is an add-on to cargo that extends it with commands helpful in the development of smart contracts. You can check what can be done with it by invoking cargo contract --help. We will very soon use it to create our very first ink! smart contract.

Last updated