LUMOS in 5 Minutes: Your First Solana Schema
Source: Dev.to

Want type‑safe Rust + TypeScript for your Solana app? Let’s get you from zero to a 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 and add:
#[solana]
#[account]
struct PlayerAccount {
wallet: PublicKey,
level: u16,
experience: u64,
equipped_items: [PublicKey],
}
#[solana]
struct MatchResult {
player: PublicKey,
opponent: Option,
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/arrayOption– 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,
}
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) -> 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';
import { PublicKey, Connection } from '@solana/web3.js';
async function getPlayer(pubkey: PublicKey, connection: Connection): Promise {
const accountInfo = await connection.getAccountInfo(pubkey);
if (!accountInfo) throw new Error('Account not found');
return PlayerAccountBorshSchema.deserialize(accountInfo.data);
}
You’re Done!
In 5 minutes you:
- ✅ Installed LUMOS CLI
- ✅ Created your first
.lumosschema - ✅ 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