Want type-safe Rust + TypeScript for your Solana app? Let's get you from zero to working schema in exactly 5 minutes.
Minute 1: Installation
cargo install lumos-cli
Verify:
lumos --version
# Output: lumos-cli 0.1.0
No Rust? Use npm instead:
npx @getlumos/cli --version
Minute 2: Initialize Project
lumos init my-game
cd my-game
This creates:
my-game/
├── schema.lumos ← Your schema definition
├── lumos.toml ← Configuration
└── README.md ← Getting started guide
Minute 3: Write Your Schema
Open schema.lumos:
#[solana]
#[account]
struct PlayerAccount {
wallet: PublicKey,
level: u16,
experience: u64,
equipped_items: [PublicKey],
}
#[solana]
struct MatchResult {
player: PublicKey,
opponent: Option<PublicKey>,
score: u64,
timestamp: i64,
}
What's happening:
-
#[solana]- Solana-specific type -
#[account]- Anchor account (uses Anchor macros) -
PublicKey- Maps toPubkeyin Rust,PublicKeyin TS -
[PublicKey]- Vector/array -
Option<T>- Optional value
Minute 4: Generate Code
lumos generate schema.lumos
Output:
Generating Rust code
Wrote ./generated.rs
Generating TypeScript code
Wrote ./generated.ts
Finished generated 2 type definitions
Rust Output (generated.rs)
use anchor_lang::prelude::*;
#[account]
pub struct PlayerAccount {
pub wallet: Pubkey,
pub level: u16,
pub experience: u64,
pub equipped_items: Vec<Pubkey>,
}
TypeScript Output (generated.ts)
import { PublicKey } from '@solana/web3.js';
import * as borsh from '@coral-xyz/borsh';
export interface PlayerAccount {
wallet: PublicKey;
level: number;
experience: number;
equipped_items: PublicKey[];
}
export const PlayerAccountBorshSchema = borsh.struct([
borsh.publicKey('wallet'),
borsh.u16('level'),
borsh.u64('experience'),
borsh.vec(borsh.publicKey(), 'equipped_items'),
]);
Minute 5: Use in Your Project
Anchor Program
mod generated;
use generated::*;
#[program]
pub mod my_game {
use super::*;
pub fn create_player(ctx: Context<CreatePlayer>) -> Result<()> {
let player = &mut ctx.accounts.player;
player.wallet = *ctx.accounts.user.key;
player.level = 1;
player.experience = 0;
Ok(())
}
}
TypeScript Client
import { PlayerAccount, PlayerAccountBorshSchema } from './generated';
async function getPlayer(pubkey: PublicKey): Promise<PlayerAccount> {
const accountInfo = await connection.getAccountInfo(pubkey);
return PlayerAccountBorshSchema.deserialize(accountInfo.data);
}
You're Done!
In 5 minutes you:
✅ Installed LUMOS CLI
✅ Created your first .lumos schema
✅ Generated type-safe Rust + TypeScript
✅ Learned the complete workflow
What you got:
- Type-safe schemas shared between languages
- Automatic Borsh serialization
- Zero manual boilerplate
- Anchor-ready code
Next Steps
Questions? Drop them below!
Top comments (0)