🏗️ Steel
Steel is a new Solana smart contract framework. It provides a library of helper functions, macros, and code patterns for building safe and maintainable smart contracts on the Solana blockchain.
Notes
- Steel is under active development. All interfaces are subject to change.
- This code is unaudited. Use at your own risk!
Todos
- Localnet toolchain.
- Mainnet toolchain.
- Passthrough cargo args.
- IDL generation.
-
Helper functions for simple lamport transfers. -
Helper functions to emit events (wrap sol_log_data). -
Custom error messages on account validation checks. -
Helper function to close AccountInfos. -
CLI with init script. -
Account parsers and validation.
Get started
Install the Steel CLI:
Use the new command to create a new project:
Compile your program using the Solana toolchain:
Test your program using the Solana toolchain:
File structure
While not strictly enforced, we recommend organizing your Solana program with the following file structure. We have found this pattern to improve code readability, separating the contract interface from its implementation. It scales well for complex contracts.
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
Accounts
Use the account! macro to link account structs with a discriminator and implement basic serialization logic.
use *;
account!;
account!;
Instructions
Use the instruction! macro to link instruction data with a discriminator and implement basic serialization logic.
use *;
instruction!;
instruction!;
Errors
Use the error! macro to define custom errors.
use *;
error!;
Events
Use the event! macro to define custom events.
use *;
event!;
Program
Entrypoint
Use the entrypoint! macro to streamline the program entrypoint.
use *;
use *;
use *;
use *;
entrypoint!;
Validation
Use chainable parsers and assertions to validate account data.
use *;
use *;
CPIs
Use helper functions to execute common tasks like creating accounts and transferring tokens.
use *;
use *;