DEV Community

Son DotCom πŸ₯‘πŸ’™
Son DotCom πŸ₯‘πŸ’™

Posted on

πŸ“˜EP01 - Intro to Rust and Solana Dev Setup

Welcome to the first episode of our Rust for Solana Bootcamp β€” a hands-on journey to becoming a smart contract engineer on Solana using Rust. In this class, we’ll explore why Rust is the language of choice for Solana, and walk through the complete environment setup to get you building on the blockchain

Today, we’re starting with:

  • Why Rust is the go-to language for Solana development
  • How to set up your development environment
  • Your first Rust CLI app
  • A bonus intro to Anchor

🧠 Why Rust for Solana?

Solana is one of the fastest blockchains β€” boasting over 65,000 TPS β€” and it's written entirely in Rust. Here's why Rust is perfect for the job:

βœ… Performance & Safety

Rust guarantees memory safety at compile time, with no garbage collector, allowing you to write blazing fast and reliable code.

βœ… Precise Control

With its ownership and borrowing model, Rust gives you precise control over your memory layout β€” a must for writing smart contracts.

βœ… No Runtime Crashes

Rust’s compiler catches nulls, uninitialized variables, and data races before they happen.


🧰 Prerequisites

  • A machine running Linux, macOS, or WSL (Windows Subsystem for Linux)
  • Familiarity with any programming language
  • Curiosity and willingness to learn πŸ’ͺ

πŸ”§ Step-by-Step Setup for Rust + Solana Dev

🟠 1. Install Rust + Cargo

Run this command:

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

Check that Rust is installed:

rustc --version
cargo --version
Enter fullscreen mode Exit fullscreen mode

βœ… cargo is Rust’s build tool and package manager.


🟣 2. Install the Solana CLI

sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
Enter fullscreen mode Exit fullscreen mode

Confirm it works:

solana --version
Enter fullscreen mode Exit fullscreen mode

Set your network to Devnet:

solana config set --url https://api.devnet.solana.com
Enter fullscreen mode Exit fullscreen mode

πŸ”΅ 3. Install Anchor (Solana's Rust Framework)

cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked
Enter fullscreen mode Exit fullscreen mode

Anchor abstracts away boilerplate and makes Solana smart contract dev enjoyable.

Test the install:

anchor --version
Enter fullscreen mode Exit fullscreen mode

πŸ§ͺ Let’s Write Your First Rust App

Run this in your terminal:

cargo new hello_rust
cd hello_rust
Enter fullscreen mode Exit fullscreen mode

Edit src/main.rs:

fn main() {
    println!("πŸš€ Hello, Solana Developer!");
}
Enter fullscreen mode Exit fullscreen mode

Run it:

cargo run
Enter fullscreen mode Exit fullscreen mode

You should see:

πŸš€ Hello, Solana Developer!
Enter fullscreen mode Exit fullscreen mode

Boom. You're now a Rustacean! πŸ¦€


πŸ“– Assignment (Do This Now)

  1. Install Rust, Solana CLI, and Anchor
  2. Create a new Rust CLI project named greeter
  3. Accept the user's name from terminal input and greet them:
use std::io;

fn main() {
    println!("What's your name?");
    let mut name = String::new();
    io::stdin().read_line(&mut name).expect("Failed to read input");
    println!("Welcome to Solana, {}!", name.trim());
}
Enter fullscreen mode Exit fullscreen mode

🧠 Practice Exercises

1. Get Your Public Key

Run:

solana address
Enter fullscreen mode Exit fullscreen mode

Then, print it in your Rust app using:

println!("My Solana address: {}", YOUR_PUBKEY_HERE);
Enter fullscreen mode Exit fullscreen mode

2. Add a Balance Checker (Mock)

Add a variable let balance = 2.5; and print if the user is eligible for an airdrop based on their balance.


🧨 Bonus: Initialize Your First Anchor Project

anchor init mysolanaapp
cd mysolanaapp
anchor build
Enter fullscreen mode Exit fullscreen mode

You’ll see:

Program ID: ...
Built in target/deploy/
Enter fullscreen mode Exit fullscreen mode

Just like that, your first on-chain Solana program is ready to deploy!


🎯 What’s Next?

In the next episode EP02 – Rust Ownership & Borrowing Explained, we’ll explore Rust’s ownership model, borrowing rules, and how it leads to memory safety β€” critical for writing secure blockchain programs.


πŸ™Œ Let’s Connect

  • πŸ’¬ Questions? Drop a comment below
  • 🧠 Want to follow the full course? Bookmark or follow me
  • πŸ“¦ GitHub repo for this series:Here

If you liked this post, consider clapping πŸ‘ and sharing with other Rust-curious blockchain devs!

Top comments (0)