Getting Set Up
-
Install or update Rust:
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
-
Add the WebAssembly (Wasm) toolchain:
rustup target add wasm32-unknown-unknown
NEAR smart contracts need to be compiled to 32-bit Wasm with architecture and platform both "unknown".
-
Install RAEN:
cargo install raen
This will install
raen
globally, so it doesn't matter where you run it.cargo
was installed with Rust. Cargo is the Rust package manager, like NPM for NodeJS. Rust packages are called crates.raen
is a Rust crate. -
Install
near-cli
:Prerequisite: install NodeJS.
npm install --global near-cli
There is a Rust version of near-cli in the works, but it's not ready yet. Someday
raen
will wrapnear
(or work with the new Rust-based CLI as a plugin), allowing you to only install one package. But for now, you need both. -
Configure your editor:
In Visual Studio Code, install the rust-analyzer extension.
The tools recommended by the Rust Book will give you further superpowers, making you feel comfy and productive in no time.
-
Clone the Examples repository:
git clone --depth 1 --branch v0.0.4 https://github.com/raendev/examples.git --recursive raen-examples
This will clone github.com/raendev/examples to a folder called
raen-examples
. -
Build with RAEN:
Change into
raen-examples/contracts/counter
, then build:raen build --release
This wraps
cargo build --release
, adding some extra goodies.It may take a minute. Rust fetches dependencies and compiles your project in one step. Subsequent runs will go faster.
If you skip this, the editor setup from Step 5 won't work. The help docs shown by your editor are fetched along with the dependencies themselves.
Now you're ready to play with some Rust code. Let's go!