Source: https://x.com/HardhatChad/status/1838919676510044523
Introducing: Steel
Steel is a new modular framework for building smart contracts on Solana. Write programs with minimum boilerplate and maximum flexibility.
๐งต
โ
Background
While developing ORE, I decided not to use Anchor, the most popular smart contract framework on Solana, and instead wrote our contract in vanilla Rust. I made this decision partly for the learning experience, but also to optimize contract performance.
/2
โ
Utils
As the codebase evolved, I began refactoring out various helper functions and macros into a utils folder. This folder has since become the bedrock of every new program we are developing at Regolith Labs (pools, boosts, and others).
/3
โ
Formalization
Through conversations with @cavemanloverboy @Eliascm17 @NotDeGhost and others, I came to realize this utils folder could form the foundation of a new modular program framework. So today I’m excited to formally release it as Steel.
https://crates.io/crates/steel
/4
Modularity
While “modularity” is kind of a meme in our industry, we like to call Steel modular because, unlike Anchor, you can use just the bits and pieces that are helpful to you without being forced to adopt everything it has to offer.
/6
โ
Accounts
For accounts, we use a single enum to manage discriminators and a struct for each account type. The account! macro helps link these types and implement basic serialization logic.
/7
โ
Instructions
For instructions, we similarly use a single enum to manage discriminators and a struct for each instruction args type. The instruction! macro helps link these types and implement basic serialization logic.
/8
โ
Entrypoint
Inside the program, Steel offers helper functions for removing entrypoint boilerplate and parsing instructions before dispatching to the implementation logic.
/9
โ
Loaders
In instructions, Steel offers “loaders” for parsing and validating account data. This is currently the area that needs the most work. In a future version, these loaders should return mutable/readonly references to the inner account data.
/10
https://preview.redd.it/s4kwgk1c00rd1.png?width=679&format=png&auto=webp&s=98764862b462addbbb8801e56d897567acd09709
CPIs
Steel additionally provides simplified interfaces for common CPIs like creating PDAs, creating token accounts, transferring tokens, minting tokens, burning tokens, etc.
/11
https://preview.redd.it/3vnkt3ae00rd1.png?width=680&format=png&auto=webp&s=0c98cdcd22c48f9e3806eb49678fb31e96170709
File structure
Finally, we provide a recommended folder structure for your programs, separating the api/ and program/ crates. While not strictly enforced, we have found this pattern to improve code readability and scale well with program complexity.
/12
https://preview.redd.it/napr69cg00rd1.png?width=680&format=png&auto=webp&s=a32cc4cb8a770c19fac983b45ce267bf93b0a8e7
Disclaimer
There are a lot of missing features. From an init script to IDL generation, loader return values and others, Steel is very much a work in progress. Another thing that would be cool to add is the no-std-entrypoint recently developed for high performance programs.
/13
โ
Contribute
We are deeply committed to open-source development at Regolith Labs and always looking for ways to contribute back to the Solana community. If you would like to contribute to Steel, feel free to submit a PR and tag me or @bigtimetapin for review.
Build on!
/fin
โ