How to set up Rust and NEAR for Blockchain/Web3 Development

How to set up Rust and NEAR for Blockchain/Web3 Development

This post covers the setup procedure for Rust development on Linux-based OS, Ubuntu.

Chris Achinga
·Jun 8, 2022·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Table of contents

  • Installing Rust (Ubuntu/Linux)
  • Installing near-cli
  • Conclusion
  • Resources:

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

Screenshot from 2022-06-08 14-55-45.png

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

Screenshot from 2022-06-08 15-05-51.png

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:

 
Share this