|
| 1 | +# Steel Framework Implementation for Solana Program Examples |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +This PR adds **Steel framework** implementations for two basic Solana programs: |
| 6 | + |
| 7 | +1. **transfer-sol** - Demonstrates SOL transfers using both CPI and direct lamport manipulation |
| 8 | +2. **account-data** - Demonstrates creating and storing structured data in program-owned accounts |
| 9 | + |
| 10 | +## What is Steel? |
| 11 | + |
| 12 | +Steel is a lightweight Solana program framework (v4.0.4) by Regolith Labs that provides: |
| 13 | +- Minimal boilerplate with helper macros (`account!`, `instruction!`, `error!`, `event!`) |
| 14 | +- Byte-based serialization using `bytemuck` (Pod/Zeroable traits) |
| 15 | +- Account validation helpers (`is_signer()`, `is_writable()`, `has_owner()`, etc.) |
| 16 | +- Type-safe instruction parsing with `parse_instruction()` |
| 17 | +- Chainable validation methods for cleaner code |
| 18 | + |
| 19 | +## Implementation Details |
| 20 | + |
| 21 | +### Directory Structure |
| 22 | + |
| 23 | +Each implementation follows the established pattern: |
| 24 | + |
| 25 | +``` |
| 26 | +basics/{program-name}/steel/ |
| 27 | +├── program/ |
| 28 | +│ ├── Cargo.toml |
| 29 | +│ ├── src/ |
| 30 | +│ │ └── lib.rs |
| 31 | +│ └── tests/ |
| 32 | +│ └── test.rs |
| 33 | +├── tests/ |
| 34 | +│ ├── test.ts |
| 35 | +│ └── instruction.ts (transfer-sol only) |
| 36 | +├── package.json |
| 37 | +└── tsconfig.json |
| 38 | +``` |
| 39 | + |
| 40 | +### Key Features |
| 41 | + |
| 42 | +**transfer-sol/steel:** |
| 43 | +- Implements two transfer methods: CPI via system program and direct lamport manipulation |
| 44 | +- Uses Steel's `parse_instruction()` for type-safe instruction parsing |
| 45 | +- Demonstrates Steel's account validation helpers |
| 46 | +- Includes both Rust (litesvm) and TypeScript (solana-bankrun) tests |
| 47 | + |
| 48 | +**account-data/steel:** |
| 49 | +- Creates program-owned accounts with structured data |
| 50 | +- Uses `bytemuck` for zero-copy serialization |
| 51 | +- Demonstrates rent calculation and account creation via CPI |
| 52 | +- Fixed-size byte arrays for string fields (32 bytes each) |
| 53 | + |
| 54 | +### Testing |
| 55 | + |
| 56 | +Both implementations include: |
| 57 | +- Rust unit tests using `litesvm` (program/tests/test.rs) |
| 58 | +- TypeScript integration tests using `solana-bankrun` (tests/test.ts) |
| 59 | +- Full test coverage matching existing framework implementations |
| 60 | + |
| 61 | +### Build Commands |
| 62 | + |
| 63 | +```bash |
| 64 | +# Build program |
| 65 | +pnpm build |
| 66 | + |
| 67 | +# Run tests |
| 68 | +pnpm build-and-test |
| 69 | + |
| 70 | +# Deploy |
| 71 | +pnpm deploy |
| 72 | +``` |
| 73 | + |
| 74 | +## Changes Made |
| 75 | + |
| 76 | +### Modified Files |
| 77 | +- `Cargo.toml` - Added steel/program workspace members and steel dependency |
| 78 | + |
| 79 | +### New Files |
| 80 | +- `basics/transfer-sol/steel/` - Complete Steel implementation |
| 81 | +- `basics/account-data/steel/` - Complete Steel implementation |
| 82 | + |
| 83 | +## Bounty Information |
| 84 | + |
| 85 | +This PR is submitted for the **Superteam Earn bounty**: "Create Solana Programs: Part 1" |
| 86 | +- Bounty ID: 3a73f71c-5cc4-4b72-ae63-028651ed3655 |
| 87 | +- Reward: $200-500 USDC per program per framework |
| 88 | +- Framework: Steel (new framework addition) |
| 89 | +- Programs: transfer-sol ($200), account-data ($300) |
| 90 | + |
| 91 | +## Testing Checklist |
| 92 | + |
| 93 | +- [x] Programs compile successfully with `cargo check` |
| 94 | +- [x] Rust tests pass with `cargo test` |
| 95 | +- [x] TypeScript tests use solana-bankrun |
| 96 | +- [x] Code formatted with Biome (`pnpm fix`) |
| 97 | +- [x] Follows existing project structure |
| 98 | +- [x] Package.json includes required scripts |
| 99 | +- [x] Workspace Cargo.toml updated |
| 100 | + |
| 101 | +## Related Documentation |
| 102 | + |
| 103 | +- Steel Framework: https://github.com/regolith-labs/steel |
| 104 | +- Steel Docs: https://docs.rs/steel/latest/steel/ |
| 105 | +- Contributing Guidelines: CONTRIBUTING.md |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +**Author**: Claude Opus 4.6 (wangxiaofei860208-source) |
| 110 | +**Submitted**: 2026-04-17 |
0 commit comments