Table of Contents
sbpf
A simple scaffold to bootstrap sBPF Assembly programs.
Installation
Usage
To view all the commands you can run, type sbpf help. Here are the available commands:
init: Create a new project scaffold.build: Compile into a Solana program executable.deploy: Build and deploy the program.test: Test the deployed program.e2e: Build, deploy, and test a program.clean: Clean up build and deploy artifacts.disassemble: Disassemble a Solana program executable.debug: Debug an sBPF assembly program.help: Print this message or the help of the given subcommand(s).
Usage: sbpf <COMMAND>
Commands:
init Create a new project scaffold
build Compile into a Solana program executable
deploy Build and deploy the program
test Test deployed program
e2e Build, deploy and test a program
clean Clean up build and deploy artifacts
disassemble Disassemble a Solana program executable
debug Debug an sBPF assembly program
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Command Details
Initialize a Project
To create a new project, use the sbpf init command. By default, it initializes a project with Rust tests using Mollusk. You can also initialize a project with TypeScript tests using the --ts-tests option.
Examples
Create a new project with Rust tests (default)
Create a new project with TypeScript tests
After initializing the project, you can navigate into the project directory and use other commands to build, deploy, and test your program.
Disassembler
The disassembler converts a Solana program executable (ELF) into human-readable sBPF assembly.
Debugger
The debugger provides an interactive REPL for stepping through sBPF assembly programs.
Debug an assembly file:
Debug an ELF file:
Input:
To debug programs that require input, the debugger accepts a JSON file (or JSON string) containing the instruction being executed and the accounts involved. Pass it using the --input flag:
The JSON should contain the following information:
instruction: The instruction to execute, including the program ID, account metas, and instruction data.accounts: The account states. Thedatafield in each account and instruction should be base58 encoded.
Example:
Advanced Usage
You can override the default linker with a custom linker file by including it in the src directory with the same name as your program. For example:
src/example/example.s
src/example/example.ld
WebAssembly
The assembler is also available as a WebAssembly package for Node.js, browsers, and bundlers. See npm/README.md.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
PRs welcome!