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)