Want to build on Solana? Discover how to use Rust and Anchor in our quick guide. Click to learn more!
If you've been following the wild world of blockchain development, you've probably heard of Solana. But what makes it stand out? Simply put, speed and scalability. Solana can handle thousands of transactions per second (TPS), making it one of the fastest blockchains out there.
But enough about TPS—let's talk about something even more interesting: building on Solana using Rust and Anchor. Ready to dive in? Let's go!
Ever heard of smart contracts? Of course, you have. But on Solana, we call them programs. These aren’t just any smart contracts—they're the logic that powers decentralized applications (dApps) on the Solana blockchain. Imagine programs as on-chain accounts storing executable logic, ready to be called into action by a trigger known as an instruction.
So, what’s cool about Solana programs? Well, they’re stateless, which means they don’t store any data themselves. Instead, they can create new accounts to store and manage data. This stateless design helps keep the blockchain efficient and scalable.
When it comes to writing Solana programs, Rust is the go-to language. Why Rust? Because it’s fast, safe, and provides fine-grained control over memory management—crucial for blockchain development. But here's where it gets even better: you can use Rust with or without frameworks.
In the decentralized world, trust is everything. That’s why verifiable builds are so important on Solana. A verifiable build ensures that the on-chain program matches the publicly available source code. This level of transparency builds trust among users and developers alike.
Ready to secure your Solana smart contracts? Take the first step towards a safer blockchain journey. Request an Audit with QuillAudits today & ensure your contracts are robust and secure!
In this tutorial, you'll:
Install Rust and Cargo:
If you haven’t already, install Rust and Cargo by following the official guide:
1curl --proto '=https' --tlsv1.2 -sSf <https://sh.rustup.rs> | sh
2
Install Solana CLI:
The Solana Command Line Interface (CLI) is essential for interacting with the Solana blockchain. Install it using the following command:
1sh -c "$(curl -sSfL <https://release.solana.com/stable/install>)"
2
Create a New Project:
Create a new directory for your project and navigate into it:
1mkdir solana-hello-world && cd solana-hello-world
2
Initialize a New Cargo Project:
Create a new Rust project with Cargo:
1cargo new --lib hello_world
2cd hello_world
3
Set Up Your Program:
Open the lib.rs
file in your favorite code editor and replace the contents with the following:
This basic program logs "Hello, Solana!" whenever it's invoked.
Build Your Program:
Compile your program to ensure there are no errors:
1cargo build-bpf
2
Create a New Wallet:
Generate a new Solana wallet for Devnet:
1solana-keygen new --outfile ~/my-solana-wallet.json
2solana config set --keypair ~/my-solana-wallet.json
3
Airdrop SOL to Your Wallet:
Request some SOL tokens to deploy your program on Devnet:
1solana airdrop 2
2
Deploy Your Program:
Deploy your program to the Solana blockchain:
1solana program deploy ./target/deploy/hello_world.so
2
Note the program's public key, which will be used to interact with it.
Create a Client:
Write a simple Rust client to call your program:
Run Your Client:
Execute the client to interact with your program:
1cargo run
2
If successful, you’ll see your transaction's signature in the console, and the "Hello, Solana!" message will be logged on Solana Explorer.
In this tutorial, you'll:
Install Rust and Cargo:
Follow the steps in the previous tutorial to install Rust and Cargo.
Install Anchor:
Install the Anchor CLI via Cargo:
1
2cargo install --git <https://github.com/coral-xyz/anchor> avm --locked
3anchor upgrade
4
5
Set Up Your Project:
Create a new Anchor project:
1
2anchor init hello_anchor
3cd hello_anchor
4
5
Write Your Program:
Open the lib.rs
file in the programs/hello_anchor/src/
directory and replace the contents with:
This program logs "Hello, Anchor!" to the console when executed.
Build Your Program:
Compile your Anchor program:
1anchor build
2
Deploy to Devnet:
Deploy your program to Solana Devnet:
1anchor deploy
2
Your program's public key will be displayed in the terminal after deployment.
Set Up Your Client:
Open the tests/hello_anchor.ts
file and replace the contents with:
Run the Client:
Execute the client test to interact with your program:
1anchor test
2
After running the test, check the Solana Explorer for your transaction, where you’ll see the "Hello, Anchor!" message.
Building on Solana is more than just writing programs; it’s about creating the future of decentralized applications. Whether you choose to go full Rust or embrace the simplicity of Anchor, Solana offers the tools and infrastructure to bring your ideas to life. So, what will you build next?
When building and deploying on Solana, it’s crucial to ensure the security of your project. Make sure to audit your code with a reputable firm like QuillAudits to safeguard your work and protect your users.
Join 1400+ leaders who secured themselves from losing Billion Dollars.
Feel free to dive deeper into Solana’s documentation, experiment with different setups, and don’t hesitate to share your experience. Happy coding!
Contents
Get updates on our community, partners, events, and everything happening across the ecosystem — delivered straight to your inbox.
Subscribe Now!
Office 104/105 Level 1, Emaar Square, Building 4 Sheikh Mohammed Bin Rashid Boulevard Downtown Dubai, United Arab Emirates P.O box: 416654
Privacy PolicyAll Rights Reserved. © 2025. QuillAudits - LLC
Office 104/105 Level 1, Emaar Square, Building 4 Sheikh Mohammed Bin Rashid Boulevard Downtown Dubai, United Arab Emirates P.O box: 416654
audits@quillaudits.comAll Rights Reserved. © 2025. QuillAudits - LLC
Privacy Policy