Lightweight Virtual Machine
for Solana
A high-performance, gas-optimized VM designed specifically for Solana blockchain
KEY FEATURES
⚡ High Performance
impl VM {
fn execute(&mut self) -> ProgramResult {
while self.pc < self.code.len() {
self.gas_metering.charge_gas(
self.config.base_cost
)?;
// Optimized execution loop
}
Ok(())
}
}
- → Sophisticated gas metering
- → Efficient memory management
- → Optimized instruction set
🔒 Secure by Design
impl SecurityChecker {
fn validate_account(&self) -> ProgramResult {
if !account.is_writable {
return Err(VMError::AccountNotWritable);
}
// Additional security checks
Ok(())
}
}
- → Built-in security checks
- → Memory safety guarantees
- → Account validation
🔧 Developer Friendly
// Simple addition program
let program = vec![
0x01, 0x05, // PUSH1 5
0x01, 0x03, // PUSH1 3
0x10, // ADD
0xFF // HALT
];
- → Simple instruction set
- → Comprehensive debugging
- → Clear documentation
🌐 Solana Native
impl SPLOperations {
fn execute_spl_op(&self, op: SPLOperation) {
match op {
SPLOperation::Transfer => self.token_transfer()?,
SPLOperation::MintTo => self.token_mint_to()?,
// More SPL operations
}
}
}
- → SPL token support
- → Cross-program invocation
- → Native account handling
QUICK START
// Create a new lessVM instance
let program = vec![
OpCode::Push1 as u8, 5, // Push 5 onto stack
OpCode::Push1 as u8, 3, // Push 3 onto stack
OpCode::Add as u8, // Add them together
OpCode::Log as u8, // Log result
OpCode::Halt as u8 // Stop execution
];
let mut vm = VM::new(&program, accounts);
vm.execute()?;
DOCUMENTATION
Command Line
- → Installation Guide
- → Project Management
- → Build & Deploy
- → Development Tools
Architecture
- → Stack-based VM
- → 32-slot stack depth
- → 1024 bytes memory
- → Optimized gas model
Instructions
- → Stack Operations
- → Math Operations
- → Memory Access
- → Control Flow
Solana Integration
- → Account Management
- → Token Operations
- → CPI Support
- → Security Model
Examples
- → Basic Programs
- → Token Transfers
- → Smart Contracts
- → Advanced Usage