How to set up Rust and NEAR for Blockchain/Web3 Development
Chris Achinga
Posted on June 8, 2022
Near protocol is a decentralized application platform that gives developer-friendly features to build and develop smart contracts.
Near offers the platform to build smart contracts in Rust and deploy them. By default, Near supports Rust and AssemblyScript. Rust is recommended for its greater developer experience when it comes to memory allocation and a minimal runtime, among other great reasons.
Installing Rust (Ubuntu/Linux)
To install Rust, follow the steps below:
Install Curl
If you don't have curl installed, use the scripts below:
sudo apt update
sudo apt install curl
Install Rust
To install Rust, paste and run the script below on your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Configure your shell using:
source $HOME/.cargo/env
To confirm a successful installation, run the following in a terminal:
rustup
After that, run
sudo apt-get install build-essential
Add wasm
target to your toolchain
rustup target add wasm32-unknown-unknown
To test out for the installation, create a simple Hello, World!
program in rust:
On an empty folder create a file named: main.rs
and add the following:
fn main() {
println!("Hello, world!");
}
Save the file and compile the code using:
rustc main.rs
Run the simple program:
./main
If Hello, world! did print, congratulations! You have successfully installed Rust
Installing near-cli
To install thenear-cli
simply use:
npm install -g near-cli
More on near-cli
can be found here.
Conclusion
The post takes you through installing Rust and near-cli
for blockchain development.
Resources:
Posted on June 8, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.