Steel
Steel is a modular framework for building smart contracts on Solana. It provides of a set of helper functions, macros, and code patterns for scaffolding smart contracts. Steel is generally designed to be unopinionated, minimizing boilerplate and maximizing flexibility.
Notes
- This codebase is under active development. All interfaces are subject to change.
- There is currently no CLI, init script, or custom localnet toolchain.
- Use
solana build-sbfto build your programs. - The account "loaders" currently do not yet return readable or mutable account references.
- The API macros currently do not support IDL generation.
File structure
While not strictly enforced, we recommend organizing your Solana program with the following file structure. We have found this pattern improves code readability, separating the contract interface from its implementation, and scales well as contract complexity increases.
Cargo.toml (workspace)
⌙ api
⌙ Cargo.toml
⌙ src
⌙ consts.rs
⌙ error.rs
⌙ event.rs
⌙ instruction.rs
⌙ lib.rs
⌙ loaders.rs
⌙ sdk.rs
⌙ state
⌙ mod.rs
⌙ account_1.rs
⌙ account_2.rs
⌙ program
⌙ Cargo.toml
⌙ src
⌙ lib.rs
⌙ instruction_1.rs
⌙ instruction_2.rs
API
Steel offers a collection of simple macros for defining your contract API and the basic building blocks of your program.
Accounts
use *;
/// Enum for account discriminators.
/// Struct for account state.
account!;
Instructions
use *;
/// Enum for instruction discriminators.
/// Struct for instruction args.
instruction!;
Errors
use *;
/// Enum for error types.
error!;
Events
use *;
/// Struct for logged events.
event!;
Program
In your instruction implementations, Steel offers helper functions for validating common types of accounts and executing CPIs.
Entrypoint
use MyInstruction;
use *;
use *;
entrypoint!;
Loaders
use *;
CPIs
use *;