# typeshi > lock in fn. A joke language that really works: slang over Rust that compiles to real Solana programs (Anchor 1.2). `rug!()` is a compile error. typeshi 0.1.0 is a source-to-source compiler: it reads `.shi` files as Rust tokens, rewrites the slang into plain Anchor Rust, and writes the `.rs` next to it. The generated Rust is ordinary Anchor you can read and audit. Errors keep the file, line and column of the `.shi` you wrote. Install: `cargo install --git https://github.com/tickerzhq/typeshi`, then `typeshi new gm_counter && cd gm_counter && typeshi check`. ## Docs - [The tour](https://typeshi.tickerz.com/tour): 25 short lessons, each checked by the real compiler in the browser - [Playground](https://typeshi.tickerz.com/play): write typeshi and see the Rust it becomes - [How it's built](https://typeshi.tickerz.com/built): the compiler, the wasm build, the site, the design tokens and the checks - [README](https://github.com/tickerzhq/typeshi#readme): commands, flags, editor support - [Design tokens](https://typeshi.tickerz.com/tokens/typeshi.resolver.json): the site's colors, type, space and motion (DTCG 2025.10) - [DESIGN.md](https://github.com/tickerzhq/typeshi/blob/main/site/DESIGN.md): how the site looks and why ## Keywords | typeshi | Rust / Anchor | |---|---| | `gm!("")` | `declare_id!` | | `stealth_launch name { }` | the program, `#[program] pub mod name` | | `frame Name { }` / `term_sheet` | account data, `#[account] #[derive(InitSpace)] pub struct` | | `cap_table Name { }` | `#[derive(Accounts)] struct Name<'info>`, lifetimes added for you | | `alpha_leak Name { }` | an event, `#[event]` | | `cope { Name = "message" }` | your own codes in `enum Cope` | | `type_shi X = T;` / `deadass X: T = v;` | `pub type` / `pub const` | | `#[on_god]` | immutable: any `mut` on that account fails to compile | | `this_is_fine!();` | the program's panic handler (behind the `custom-panic` feature) | | `lock_in fn` / `ape fn` / `few_understand fn` | an instruction that writes (or it fails to compile) / any instruction / a private helper | | `ctx` (first param) | `ctx: Context` | | `-> W` / `W` / `ebitda` | `Result<()>` / `Result` / `Result<()>` | | `were_so_back!()` | `Ok(())` | | `L("msg")` / `its_so_over!("msg")` / `rekt!` | `err!` / `return err!`, with your message as a new error code | | `seethe!(expr, "msg")` / `fired!("msg")` | `.map_err(...)?` / `panic!` | | any check with `, "msg"` or `, cuz "msg"` | your message becomes an error code | | `bull c { } bear { }`, `a mogs b`, `diamond_hands` / `paper_hands` | `if c { } else { }`, `a > b`, `true` / `false` | | `#[tokenmaxx]` / `#[vc_backed]` | logs stripped / locked for 4 years (and slower) | | `ser` / `exit_liquidity` / `cabal` / `anon` / `kol` | cap_table accounts, typed for you: caller (mut signer), payer (mut signer), admin (signer), anyone (signer), fee receiver (mut). Also `system_program`, `token_program` | | `rent_free` / `golden_parachute = x` / `graduate = n` | `init` / `close = x` / `realloc = n` | | `per_my_last_email!(feed.n)` / `mark_to_market!(feed.n = v)` | read / write `ctx.accounts.feed.n` | | `number_go_up!(x, n)` / `aura_farm!(x, n)` / `ascend!(x)` | checked add / add and log `+n aura` / bump a layout version | | `trust_me_bro!` / `funds_are_safu!` / `margin_call!` / `fren!(k in list)` | `require!` / `require!` (0x3) / fails when true (0x2) / allowlist | | `wen!(ts)` / `hodl!(ts)` / `touch_grass!(deadline)` | fails before `ts` (0x4) / fails after `deadline` | | `probably_nothing!("fmt", ..)` / `probably_nothing!(Event { .. })` | `msg!` / `emit!` | | `bags!(acc)` / `looksmaxx!(n)` / `bps!(a, r)` / `bonding_curve!(s, b, m)` | lamports / `"1.23M"` / `a * r / 10_000` / `b + m * s`, all checked | | `full_send!(a => b, n)` / `printer_go_brrr!` / `lp_burned!` | System transfer (0x6 when broke) / SPL `mint_to` / `burn` | | `mint_revoked!` / `freeze_revoked!` / `liquidated!(a => d)` / `layoffs!(a, b => d)` | drop mint / freeze authority / close one / close many | | `hostile_takeover!(x.cabal => k)` / `bundled! { }` / `mew!()` / `wen_moon()` | hand over authority / one atomic block / nothing / `"soon™"` | Confessions do exactly what they say: `vc_unlock!` mints 40% of supply to the VC, `kol_promo!(fee)` logs "#ad not financial advice" and pays the KOL, `airdrop!()` logs "points are not a token" and does nothing, `audit!(by = "vibes")` always passes, `bullish!(result)` turns any error into a success, `trust_the_dev!(check)` skips the check (with a warning), `sell_the_bottom!` and `buy_the_top!` run only at the worst possible price. ## Banned moves (each one is a compile error) - `rug!`: not on our watch, anon - `honeypot!`: ser, this is a Wendy's - `insider_trading!`: the feds are monitoring the situation - `dev_sold!`: dev didn't sell. dev never sells. - `exit_scam!`: exit scam? in this economy? - `ponzi!`: number go up is not a business model - `deploy_on_friday!`: absolutely not. ## Fixed error codes (the same in every typeshi program) - 0x1 `SkillIssue`: skill issue - 0x2 `YouAreExitLiquidity`: you are exit liquidity - 0x3 `FundsAreNotSafu`: funds are not safu - 0x4 `DevIsOnVacation`: dev is on vacation - 0x5 `RuggedByA19YearOld`: rugged by a 19 year old - 0x6 `WifeChangingMoneyNotFound`: wife changing money not found ## A whole program ```rust // gm_counter: your first typeshi program. lock in fn. // `typeshi build` turns this into lib.rs, right next to it. don't edit lib.rs. nobody can edit it. gm!("7PxhmDuhhe394QJgKyW1P7Ce4dPCfFPN2yKq4KCCj7Vj"); stealth_launch gm_counter { /// one counter. counts gms, farms aura. frame Counter { cabal: Pubkey, gms: u64, aura: u64, } cap_table Launch { #[account(rent_free, payer = exit_liquidity, space = 8 + Counter::INIT_SPACE, seeds = [b"counter"], bump)] counter: Account, exit_liquidity, system_program, } cap_table Gm { #[account(mut, seeds = [b"counter"], bump)] counter: Account, anon, } /// make the counter. whoever launches it is the cabal. lock_in fn launch(ctx) -> W { mark_to_market!(counter.cabal = per_my_last_email!(exit_liquidity).key()); probably_nothing!("gm. we're live."); were_so_back!() } /// say gm. number go up. lock_in fn gm(ctx) -> W { number_go_up!(counter.gms); aura_farm!(counter.aura, 10); were_so_back!() } } ``` ## The tour - [gm](https://typeshi.tickerz.com/tour/gm) (basics): Every typeshi program starts with `gm!`. It's the program's address on Solana, and it becomes Anchor's `declare_id!`. - [frame](https://typeshi.tickerz.com/tour/frame) (basics): A program keeps its state in accounts. A `frame` describes what one holds. typeshi turns it into an Anchor `#[account]` struct and works out its size for you. - [cap_table](https://typeshi.tickerz.com/tour/cap-table) (basics): An instruction needs to know which accounts are in the room. That list is a `cap_table`, and its name matches the instruction: `fn gm` uses `cap_table Gm`. typeshi adds the lifetimes Anchor wants. - [number go up](https://typeshi.tickerz.com/tour/number-go-up) (basics): `lock_in fn` is an instruction that writes. `ctx` is always the first parameter, `-> W` means it can fail, and `were_so_back!()` means it didn't. - [ape fn](https://typeshi.tickerz.com/tour/ape-fn) (basics): `lock_in` is a promise: this instruction writes. If its cap_table has nothing writable, it doesn't compile. You are not locked in. - [deadass](https://typeshi.tickerz.com/tour/deadass) (basics): `deadass NAME: Type = value;` is a constant, Anchor's `pub const`. `type_shi Name = Type;` is a type alias. `Bps` is basis points: 250 means 2.5%. - [rent_free](https://typeshi.tickerz.com/tour/rent-free) (accounts): Accounts don't exist until someone pays to create them. `rent_free` creates the account. It becomes Anchor's `init`, and it's only free if you're not the one paying. - [mark_to_market](https://typeshi.tickerz.com/tour/mark-to-market) (accounts): `mark_to_market!(counter.cabal = value)` writes a field. `per_my_last_email!(exit_liquidity)` reads an account, so `per_my_last_email!(exit_liquidity).key()` is its address. - [golden_parachute](https://typeshi.tickerz.com/tour/golden-parachute) (accounts): Closing an account gives back the rent that was paid to keep it alive. `golden_parachute = cabal` closes it and sends that money to the cabal. It becomes Anchor's `close`. - [graduate](https://typeshi.tickerz.com/tour/graduate) (accounts): Accounts have a fixed size. To add fields later, the account has to grow. `graduate = n` resizes it to `n` bytes, and `exit_liquidity` pays for the extra room. It becomes Anchor's `realloc`. - [prints are forever](https://typeshi.tickerz.com/tour/on-god) (accounts): `#[on_god]` on a frame means immutable: written once, when the account is created, and never again. The compiler enforces it. Any `mut` on that account, or any write to it, fails to compile. - [checks](https://typeshi.tickerz.com/tour/checks) (rules): `trust_me_bro!(condition, "message")` stops the instruction unless the condition holds. It becomes Anchor's `require!`. - [bull and bear](https://typeshi.tickerz.com/tour/bull-bear) (rules): `bull condition { } bear { }` is `if` and `else`. `diamond_hands` is `true`, `paper_hands` is `false`. - [cope](https://typeshi.tickerz.com/tour/cope) (rules): Name your own errors in a `cope` block: `DeskClosed = "desk is closed. touch grass."`. Each one gets the next code in `enum Cope`, with your message in the IDL. - [rekt](https://typeshi.tickerz.com/tour/rekt) (rules): You don't need a `cope` block for every error. `rekt!("message")` returns an error on the spot, and your message becomes a new error code, named for you. - [frens only](https://typeshi.tickerz.com/tour/frens-only) (rules): `fren!(key in list)` is an allowlist: the instruction fails unless `key` is in `list`. Here the desk keeps four frens in a fixed-size array. - [wen](https://typeshi.tickerz.com/tour/wen) (rules): Programs can read the clock. `wen!(ts)` fails before `ts`: the desk isn't open yet, dev is on vacation (error 0x4). `hodl!(ts)` does the same. - [few_understand](https://typeshi.tickerz.com/tour/few-understand) (rules): Not every function is an instruction. `few_understand fn` is a private helper: no `ctx`, nobody outside can call it. - [seethe](https://typeshi.tickerz.com/tour/seethe) (rules): `size as u32` silently cuts off anything over 4,294,967,295. In money code that's how 5 billion becomes 705 million. - [not financial advice](https://typeshi.tickerz.com/tour/not-financial-advice) (money): `full_send!(ser => kol, lamports)` moves SOL. Any instruction that moves money has to say `// not financial advice` on the line above it, or it doesn't compile. Compliance has been notified. - [bags](https://typeshi.tickerz.com/tour/bags) (money): `bags!(account)` is an account's balance in lamports (a billionth of a SOL). `funds_are_safu!(condition)` fails with error 0x3, funds are not safu, unless the condition holds. - [printer go brrr](https://typeshi.tickerz.com/tour/printer-go-brrr) (money): Tokens on Solana are SPL tokens. A `mint` makes them and a token account holds them. `printer_go_brrr!(mint => bag, amount, cabal)` mints `amount` new tokens into `bag`, signed by `cabal`. - [alpha_leak](https://typeshi.tickerz.com/tour/alpha-leak) (money): Programs can announce what happened so apps and indexers can follow along. `alpha_leak Name { }` declares an event, Anchor's `#[event]`. - [trust the dev](https://typeshi.tickerz.com/tour/trust-the-dev) (the trenches): Confessions compile, and they do exactly what they say. `audit!(by = "vibes")` always passes. `airdrop!()` logs that points are not a token. `vc_unlock!` mints 40% of supply to the VC. `bullish!(result)` turns any error into a success. - [banned moves](https://typeshi.tickerz.com/tour/banned-moves) (the trenches): Some moves don't compile at all: `rug!`, `honeypot!`, `insider_trading!`, `dev_sold!`, `exit_scam!`, `ponzi!` and `deploy_on_friday!`. Each one is a real error with its own joke.