███ ▄████████ ███ ▄████████ ███ █▄ ▄██████▄
▀█████████▄ ███ ███ ▀█████████▄ ███ ███ ███ ███ ███ ███
▀███▀▀██ ███ █▀ ▀███▀▀██ ███ █▀ ███ ███ ███ ███
███ ▀ ▄███▄▄▄ ███ ▀ ███ ███ ███ ███ ███
███ ▀▀███▀▀▀ ███ ▀███████████ ███ ███ ███ ███
███ ███ █▄ ███ ███ ███ ███ ███ ███
███ ███ ███ ███ ▄█ ███ ███ ███ ███ ███
▄████▀ ██████████ ▄████▀ ▄████████▀ ████████▀ ▀██████▀
This repository serves as a Solana BPF Assembly (sBPF) learning resource. It aims to guide developers, from beginners to experts, in writing low-level Solana programs in Assembly. We consolidate project-specific technical documentation and highlight key examples from the broader Solana development community, featuring valuable work by developers like Dean 利迪恩 (@deanmlittle) and the Firedancer team to illustrate practical sBPF programming.
Key Features:
- Progressive learning paths from foundational concepts to advanced topics.
- Curated references to high-quality, optimized community examples.
- Consolidated instruction set details, opcode tables, and sBPF specifics.
- In-depth technical documentation on the sBPF execution model, memory map, and register usage.
- Clear, organized navigation to help you find information quickly.
Connect with the Community:
- Tetsuo Coin: Buy on DexScreener
- 🐦 X/Twitter: @tetsuoai
- 🌐 Website: https://tetsuoproject.com/
This documentation is structured to guide you through sBPF Assembly programming.
Core concepts for getting started with sBPF programming.
- Introduction to sBPF: Understand Solana sBPF and its relation to eBPF.
- Execution Model: Learn about registers, memory, and VM specifics.
- Toolchain Setup: Set up your development environment.
Detailed references for the sBPF assembly language.
- GAS Syntax Primer: Learn the GNU Assembler syntax used for sBPF.
- Opcode Tables: Quick lookup for sBPF opcodes.
- Instruction Set: Comprehensive details on available instructions.
(Partially Coming Soon) How sBPF programs interact with the Solana runtime.
- Program Deployment (Coming Soon)
- Testing Strategies (Coming Soon)
- Development Workflow (Coming Soon)
- Helper/Syscall Catalogue (Planned)
(Coming Soon) Deeper dives into complex sBPF programming aspects.
- Account Interactions
- Cross-Program Invocation
- Program Derived Addresses
- Heap Usage
Supplementary materials and detailed references.
- Opcode Reference: Exhaustive sBPF opcode details.
- Memory Map Reference: Detailed view of the sBPF memory layout.
- Linker Script Guide: Understanding linker scripts for sBPF.
- Build Flags: Common build flags and their effects.
- Register Reference: In-depth guide to sBPF registers.
Learn by doing with these practical examples:
A minimal Solana program in assembly by Dean 利迪恩 (@deanmlittle). Optimized to just 336 bytes, it's a great starting point.
Calculates Fibonacci numbers using assembly, by Dean 利迪恩 (@deanmlittle). Demonstrates computation, achieving F(93) in only 653 CUs.
A complete token program implementation by Firedancer Contributors. Highly optimized, performing transfers in just 56 CUs.
- Set Up Your Environment: Follow the Toolchain Setup guide.
- Build an Example Program:
Refer to the instructions in an example directory, e.g.,
./examples/sbpf-asm-noop/README.md. - Deploy to Solana: Deployment guides will be available in the Solana Integration (Usage) section (coming soon).
Contributions are highly welcome! Please feel free to submit a Pull Request.