Typhoon

Solana Sealevel Framework

Build Status Read the book License

## πŸ—’οΈ Note - **Typhoon is in active development, so all APIs are subject to change.** - **This code is unaudited. Use at your own risk.** ## πŸ“¦ Installation To get started with Typhoon, you can use the CLI tool to scaffold and manage your projects. ### CLI Install the Typhoon CLI using Cargo: ```bash cargo install --git https://github.com/exotic-markets-labs/typhoon typhoon-cli ``` ### Library If you prefer to add Typhoon to an existing Rust project: ```bash cargo add typhoon ``` ## πŸš€ Getting Started Here’s a quick example to show how Typhoon simplifies Solana program development: ```rust #![no_std] use { bytemuck::{AnyBitPattern, NoUninit}, typhoon::prelude::*, }; program_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); nostd_panic_handler!(); no_allocator!(); #[context] pub struct Init { pub payer: Mut, #[constraint( init, payer = payer, )] pub counter: Mut>>, pub system: Program, } #[context] pub struct CounterMut { pub counter: Mut>, } #[context] pub struct Destination { pub destination: Mut, } entrypoint!(); pub const ROUTER: EntryFn = basic_router! { 0 => initialize, 1 => increment, 2 => close, }; pub fn initialize(_: Init) -> ProgramResult { Ok(()) } pub fn increment(ctx: CounterMut) -> ProgramResult { ctx.counter.mut_data()?.count += 1; Ok(()) } pub fn close( CounterMut { counter }: CounterMut, Destination { destination }: Destination, ) -> ProgramResult { counter.close(&destination)?; Ok(()) } #[derive(NoUninit, AnyBitPattern, AccountState, Copy, Clone)] #[repr(C)] pub struct Counter { pub count: u64, } ``` ## πŸ› οΈ CLI Usage The Typhoon CLI helps you create and manage your projects. ### New Project ```bash typhoon new my-project --program counter ``` ### Add Program ```bash typhoon add program token ``` ### Add Instruction ```bash typhoon add handler --program counter increment ``` ## πŸ“¦ Examples Explore the [`examples`](./examples) directory for templates and use-case scenarios to kickstart your project. ## πŸ“œ License Typhoon is licensed under [Apache 2.0](./LICENSE). Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Typhoon by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.