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
Check that Rust is installed:
rustc --version
cargo --version
β
cargo
is Rustβs build tool and package manager.
π£ 2. Install the Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
Confirm it works:
solana --version
Set your network to Devnet:
solana config set --url https://api.devnet.solana.com
π΅ 3. Install Anchor (Solana's Rust Framework)
cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked
Anchor abstracts away boilerplate and makes Solana smart contract dev enjoyable.
Test the install:
anchor --version
π§ͺ Letβs Write Your First Rust App
Run this in your terminal:
cargo new hello_rust
cd hello_rust
Edit src/main.rs
:
fn main() {
println!("π Hello, Solana Developer!");
}
Run it:
cargo run
You should see:
π Hello, Solana Developer!
Boom. You're now a Rustacean! π¦
π Assignment (Do This Now)
- Install Rust, Solana CLI, and Anchor
- Create a new Rust CLI project named
greeter
- 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());
}
π§ Practice Exercises
1. Get Your Public Key
Run:
solana address
Then, print it in your Rust app using:
println!("My Solana address: {}", YOUR_PUBKEY_HERE);
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
Youβll see:
Program ID: ...
Built in target/deploy/
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)