Architecture
Chain Forge's technical architecture and design decisions.
Core Abstraction
The ChainProvider trait defines the interface for all blockchain implementations:
rust
pub trait ChainProvider {
async fn start(&mut self) -> Result<()>;
async fn stop(&mut self) -> Result<()>;
async fn get_accounts(&self) -> Result<Vec<Account>>;
async fn set_balance(&self, address: &str, amount: f64) -> Result<()>;
// ...
}Project Structure
chain-forge/
├── chains/ # Chain implementations
│ └── solana/
│ └── crates/
│ ├── accounts/ # BIP39/BIP44 derivation
│ ├── rpc/ # RPC client wrapper
│ ├── core/ # ChainProvider impl
│ └── cli/ # cf-solana binary
├── crates/ # Shared utilities
│ ├── common/ # Shared traits
│ ├── config/ # Configuration
│ └── cli-utils/ # CLI helpers
└── npm/ # TypeScript packagesSolana Implementation
The Solana implementation wraps solana-test-validator:
- Process Management: Spawns validator as subprocess
- Account Generation: BIP39/BIP44 key derivation
- Funding: Post-startup airdrops via RPC
- Lifecycle: Clean process termination
Adding New Chains
- Create
chains/<chain>/crates/{cli,core,accounts,rpc} - Implement
ChainProvidertrait - Add TypeScript package at
npm/@chain-forge/<chain>
See Also
- Development Guide
- CLAUDE.md for detailed technical docs