sBPF BooksBPF Book

Installation

Install Rust, the Solana CLI, and the sbpf toolchain on macOS or Linux.

This page covers the local toolchain needed to write, build, and deploy a Solana program in pure assembly. macOS and Linux are first-class. Windows is supported through WSL.

Quick install

The Solana CLI ships its own installer that pulls Rust, the Solana CLI, and a few common tools in one shot.

Terminal
curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash

After that, install the sbpf CLI from crates.io.

Terminal
cargo install sbpf

Verify both:

Terminal
solana --version
sbpf --version

Windows users: install WSL first, then run every command below inside the Ubuntu (WSL) terminal.

If the quick install fails or you want to install each piece individually, follow the steps below.

Install dependencies

Install Rust

The sbpf CLI is built from source via cargo. Install Rust through rustup.

Terminal
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

Reload your PATH:

Terminal
. "$HOME/.cargo/env"

Verify:

Terminal
rustc --version

Install the Solana CLI

The Solana CLI is required to deploy programs, query account state, and run a local validator.

Terminal
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"

If you use zsh (the macOS default):

Terminal
echo 'export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Terminal
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"

Add the same line to your shell rc file (~/.bashrc, ~/.zshrc) so it persists.

Verify:

Terminal
solana --version

To upgrade later:

Terminal
agave-install update

Install the sbpf CLI

sbpf is the project scaffolder, assembler driver, and deploy wrapper for pure-asm Solana programs. It is published to crates.io and installs as a regular cargo binary.

Terminal
cargo install sbpf

Verify:

Terminal
sbpf --version

Source and issues: blueshift-gg/sbpf. The companion crate sbpf-linker is only needed if you want to relink upstream BPF binaries from Rust into sBPF v0 format; pure assembly projects do not require it.

Solana CLI basics

Configure the cluster

Inspect the current configuration:

Terminal
solana config get
Config File: /Users/you/.config/solana/cli/config.yml
RPC URL: https://api.mainnet-beta.solana.com
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
Keypair Path: /Users/you/.config/solana/id.json
Commitment: confirmed

Switch cluster:

Terminal
solana config set -um    # mainnet-beta
solana config set -ud    # devnet
solana config set -ul    # localhost
solana config set -ut    # testnet

Create a wallet

Terminal
solana-keygen new

The default keypair path is ~/.config/solana/id.json. Use --outfile <path> to keep separate keypairs per cluster, then point the config at the one you want with solana config set --keypair <path>.

Print your address:

Terminal
solana address

Fund devnet

Terminal
solana config set -ud
solana airdrop 2
solana balance

Airdrops are rate-limited. If you hit a limit, use the Solana Web Faucet instead.

Run a local validator

In a separate terminal:

Terminal
solana-test-validator

Point your config at localhost:

Terminal
solana config set -ul

sbpf basics

Initialize a project

Terminal
sbpf init my_program
cd my_program

This scaffolds a Bun + Mocha test project with a single empty program under src/my_program/my_program.s and a deploy keypair under deploy/my_program-keypair.json.

Build

Terminal
sbpf build

The assembler compiles every .s file under src/ into a deployable .so under deploy/.

Deploy

Terminal
sbpf deploy my_program https://api.devnet.solana.com

sbpf deploy is a thin wrapper around solana program deploy. The deployer keypair comes from solana config get. If no URL is passed, sbpf defaults to localhost.

Disassemble

Terminal
sbpf disassemble deploy/my_program.so

Round-trips the deployed bytes back to assembly. Read the output of this command often. It is the most direct way to verify the assembler emitted what you wrote.

Shell completions

The Solana CLI ships completion generators for bash, fish, and zsh. Add them once and solana <tab> works in every new shell.

If you do not already use oh-my-zsh, ensure your ~/.zshrc has:

~/.zshrc
autoload -U compinit
compinit -i

Then:

Terminal
solana completion --shell zsh | sudo tee /usr/local/share/zsh/site-functions/_solana
exec zsh
Terminal
mkdir -p $HOME/.local/share/bash-completion/completions
solana completion --shell bash > $HOME/.local/share/bash-completion/completions/solana
exec bash
Terminal
mkdir -p $HOME/.config/fish/completions
solana completion --shell fish > $HOME/.config/fish/completions/solana.fish
source $HOME/.config/fish/config.fish

Further reading

For broader Solana development tutorials, mini-projects, and learning paths from the team behind sbpf, see the Blueshift Learn site and the blueshift-gg GitHub organization.

On this page

Edit on GitHub