Skip to content

Commit eb8d4a8

Browse files
Copilot0xrinegade
andcommitted
Add comprehensive snippet-based examples to README and docs
Co-authored-by: 0xrinegade <[email protected]>
1 parent 9b9f481 commit eb8d4a8

File tree

2 files changed

+1011
-0
lines changed

2 files changed

+1011
-0
lines changed

README.md

Lines changed: 353 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,359 @@ osvm rpc-manager devnet # Start real devnet validator
220220

221221
---
222222

223+
## 📖 Common Workflows
224+
225+
These practical, copy-paste ready examples demonstrate the most common OSVM CLI use cases.
226+
227+
### 🏃 Getting Started Workflow
228+
229+
```bash
230+
# 1. Check system health and dependencies
231+
osvm doctor
232+
233+
# Expected output:
234+
# ✅ System health check complete
235+
# ✅ Rust toolchain: 1.70+ installed
236+
# ✅ Solana CLI: installed
237+
# ✅ SSH client: available
238+
239+
# 2. Configure your Solana network
240+
osvm config set --network devnet
241+
osvm config set --keypair ~/.config/solana/id.json
242+
243+
# 3. Verify configuration
244+
osvm config show
245+
246+
# Expected output:
247+
# Current Configuration:
248+
# Network: devnet
249+
# RPC URL: https://api.devnet.solana.com
250+
# Keypair: ~/.config/solana/id.json
251+
```
252+
253+
### 🔍 AI-Powered Analysis Workflow
254+
255+
```bash
256+
# 1. Set up AI endpoint (OpenAI or Ollama)
257+
export OPENAI_URL="https://api.openai.com/v1/chat/completions"
258+
export OPENAI_KEY="sk-your-api-key-here"
259+
260+
# 2. Ask natural language questions about Solana
261+
osvm "What's the current slot height on mainnet?"
262+
263+
# Expected output:
264+
# 🤖 AI Analysis:
265+
# The current slot on Solana mainnet is approximately 245,678,901
266+
# (as of [timestamp]). This represents...
267+
# Confidence: 95%
268+
269+
# 3. Analyze a transaction
270+
osvm "Analyze transaction signature 5J8sFH3kGxNy2Bbv7vPo8hKqM9dRT4yL5KzPr6DqM2Wx"
271+
272+
# 4. Get validator performance insights
273+
osvm "How do I optimize my validator for better performance?"
274+
275+
# 5. Security audit a program
276+
osvm audit ./my-solana-program
277+
278+
# Expected output:
279+
# 🔍 Security Audit Report
280+
# ==================
281+
# Severity: HIGH - 2 issues found
282+
# Severity: MEDIUM - 5 issues found
283+
# [Detailed findings with code snippets...]
284+
```
285+
286+
### 🚀 Local Development Workflow
287+
288+
```bash
289+
# 1. Start local test validator
290+
osvm rpc-manager test --faucet-sol 1000
291+
292+
# Expected output:
293+
# ✅ Starting local test validator
294+
# ✅ Airdropping 1000 SOL to faucet
295+
# ✅ RPC endpoint: http://localhost:8899
296+
# ✅ WebSocket: ws://localhost:8900
297+
298+
# 2. Check your balance
299+
osvm balance
300+
301+
# Expected output:
302+
# Address: 7xKx...abc123
303+
# Balance: 1000.000000000 SOL
304+
305+
# 3. Deploy your program
306+
cargo build-bpf
307+
osvm deploy-program \
308+
--program target/deploy/my_program.so \
309+
--network localnet
310+
311+
# Expected output:
312+
# 🚀 Deploying program...
313+
# Program ID: BPF...xyz789
314+
# ✅ Deployment successful in 2.3s
315+
```
316+
317+
### 🔧 Remote Validator Setup Workflow
318+
319+
```bash
320+
# 1. Prepare your keypairs
321+
solana-keygen new --outfile ~/validator-keypair.json
322+
solana-keygen new --outfile ~/vote-keypair.json
323+
324+
# 2. Deploy validator to remote server
325+
osvm deploy-validator \
326+
327+
--keypair ~/validator-keypair.json \
328+
--vote-keypair ~/vote-keypair.json \
329+
--network testnet
330+
331+
# Expected output:
332+
# 🔌 Connecting to [email protected]...
333+
# ✅ SSH connection established
334+
# 📦 Installing dependencies...
335+
# ✅ Dependencies installed
336+
# 🚀 Deploying validator...
337+
# ✅ Validator deployed successfully
338+
# 📊 Status: Running
339+
# 🔗 Identity: 7xKx...abc123
340+
341+
# 3. Monitor validator status
342+
osvm node status validator-001
343+
344+
# Expected output:
345+
# Validator: validator-001
346+
# Status: ✅ Running
347+
# Network: testnet
348+
# Version: 1.18.0
349+
# Uptime: 2h 34m
350+
# Vote Account: BPF...xyz789
351+
352+
# 4. View validator logs
353+
osvm node logs validator-001 --follow
354+
```
355+
356+
### 📊 Monitoring & Troubleshooting Workflow
357+
358+
```bash
359+
# 1. Launch the monitoring dashboard
360+
osvm svm dashboard
361+
362+
# Interactive TUI showing:
363+
# - All SVMs and their status
364+
# - Resource usage (CPU, Memory, Disk)
365+
# - Network metrics
366+
# - Real-time logs
367+
368+
# 2. Check node health
369+
osvm doctor --node validator-001 --detailed
370+
371+
# Expected output:
372+
# 🏥 Health Check for validator-001
373+
# ✅ Process: Running
374+
# ✅ Network: Connected
375+
# ⚠️ Disk space: 78% used (warning)
376+
# ✅ Memory: 45% used
377+
# Recommendations:
378+
# - Consider expanding disk space
379+
380+
# 3. Auto-repair common issues
381+
osvm doctor --auto-repair
382+
383+
# Expected output:
384+
# 🔧 Auto-repair mode enabled
385+
# 🔍 Detecting issues...
386+
# ⚠️ Found: Outdated Rust toolchain
387+
# 🔧 Fixing: Updating Rust...
388+
# ✅ Fixed: Rust toolchain updated to 1.70+
389+
# ✅ All issues resolved
390+
391+
# 4. Monitor logs for errors
392+
osvm monitor-logs validator.log --auto-repair
393+
394+
# Continuously monitors logs and auto-repairs issues:
395+
# - Restarts on crash
396+
# - Handles panic recovery
397+
# - Reports anomalies
398+
```
399+
400+
### 🔌 MCP Server Integration Workflow
401+
402+
```bash
403+
# 1. List available MCP servers
404+
osvm mcp list
405+
406+
# Expected output:
407+
# Available MCP Servers:
408+
# - github-mcp-server (✅ Running)
409+
# - filesystem-server (⏸ Stopped)
410+
# - database-server (✅ Running)
411+
412+
# 2. Start an MCP server
413+
osvm mcp start filesystem-server
414+
415+
# Expected output:
416+
# 🚀 Starting MCP server: filesystem-server
417+
# ✅ Server started in 50ms (unikernel mode)
418+
# 📊 Status: Running
419+
# 🔒 Isolation: Hardware-enforced
420+
421+
# 3. List available tools from MCP server
422+
osvm mcp tools github-mcp-server
423+
424+
# Expected output:
425+
# Available Tools (github-mcp-server):
426+
# - search_repositories: Search GitHub repositories
427+
# - get_file_contents: Read file from repository
428+
# - list_commits: List commits in repository
429+
# [... more tools ...]
430+
431+
# 4. Call an MCP tool
432+
osvm mcp call github-mcp-server search_repositories \
433+
--query "solana program examples"
434+
435+
# Expected output:
436+
# 📊 Results from github-mcp-server:
437+
# Found 42 repositories:
438+
# 1. solana-labs/solana-program-library (⭐ 2.1k)
439+
# 2. coral-xyz/anchor (⭐ 1.8k)
440+
# [... more results ...]
441+
```
442+
443+
### 🧪 OVSM Research Workflow
444+
445+
```bash
446+
# 1. Execute an OVSM query for blockchain analysis
447+
osvm ovsm execute --query "What is the average transaction fee?"
448+
449+
# Expected output:
450+
# 🔬 OVSM Research Query
451+
# Query: "What is the average transaction fee?"
452+
#
453+
# [TIME: ~45s] [COST: ~0.002 SOL] [CONFIDENCE: 85%]
454+
#
455+
# Analysis:
456+
# Average fee: 0.000005 SOL (5,000 lamports)
457+
# Sample size: 10,000 transactions
458+
# Timeframe: Last 100 blocks
459+
#
460+
# Detailed Statistics:
461+
# - Mean: 0.000005 SOL
462+
# - Median: 0.000005 SOL
463+
# - 95th percentile: 0.000008 SOL
464+
# - Std dev: 0.000002 SOL
465+
466+
# 2. Analyze specific account activity
467+
osvm "Show me the transaction history for account DezX..."
468+
469+
# 3. Detect MEV opportunities
470+
osvm ovsm execute --query "Find recent MEV arbitrage opportunities"
471+
472+
# 4. Smart money tracking
473+
osvm "Track whales moving more than 1000 SOL in the last hour"
474+
```
475+
476+
### 📸 Snapshot Analysis Workflow
477+
478+
```bash
479+
# 1. Export snapshot accounts to JSON
480+
osvm snapshot export \
481+
--snapshot-dir /path/to/snapshot \
482+
--output accounts.json \
483+
--format json
484+
485+
# Expected output:
486+
# 📦 Exporting snapshot...
487+
# ✅ Exported 1,234,567 accounts
488+
# 💾 Output: accounts.json (245 MB)
489+
# ⏱️ Time: 12.3s
490+
491+
# 2. Find high-value accounts (whale hunting)
492+
osvm snapshot read \
493+
--snapshot-dir /path/to/snapshot \
494+
--min-balance 1000 \
495+
--limit 100
496+
497+
# Expected output:
498+
# 🐋 Top 100 accounts by balance:
499+
# 1. 7xKx...abc123: 1,234,567 SOL
500+
# 2. BPF1...xyz789: 987,654 SOL
501+
# [... more accounts ...]
502+
503+
# 3. Analyze token accounts
504+
osvm snapshot read \
505+
--filter-owner TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA \
506+
--limit 100
507+
508+
# 4. Compare two snapshots
509+
osvm snapshot compare \
510+
--snapshot-dir /path/to/snapshot1 \
511+
--other /path/to/snapshot2
512+
513+
# Expected output:
514+
# 📊 Snapshot Comparison:
515+
# New accounts: 12,345
516+
# Deleted accounts: 8,901
517+
# Modified accounts: 45,678
518+
# Total lamports change: +123,456,789
519+
```
520+
521+
### 🔐 Security Best Practices Workflow
522+
523+
```bash
524+
# 1. Generate secure keypairs
525+
osvm keygen --output mainnet-validator.json
526+
chmod 600 mainnet-validator.json
527+
528+
# 2. Audit your program before deployment
529+
osvm audit ./my-program --severity high
530+
531+
# Expected output:
532+
# 🔒 Security Audit Results:
533+
# HIGH: 0 vulnerabilities
534+
# MEDIUM: 2 vulnerabilities
535+
# LOW: 5 vulnerabilities
536+
#
537+
# Details:
538+
# [M1] Missing signer check in transfer function
539+
# File: src/lib.rs:45
540+
# Recommendation: Add signer validation
541+
542+
# 3. Deploy with security verification
543+
osvm deploy-program \
544+
--program target/deploy/my_program.so \
545+
--audit-first \
546+
--network mainnet
547+
548+
# 4. Monitor for security issues
549+
osvm monitor-security --continuous --alerts
550+
```
551+
552+
### 💡 Quick Tips
553+
554+
```bash
555+
# Get help for any command
556+
osvm --help
557+
osvm deploy-validator --help
558+
559+
# Use verbose mode for debugging
560+
osvm --verbose deploy-validator --host user@server
561+
562+
# Check version
563+
osvm --version
564+
565+
# Interactive AI chat mode
566+
osvm chat
567+
568+
# List all available examples
569+
osvm examples --list-categories
570+
```
571+
572+
**📚 For more examples, see [docs/examples.md](docs/examples.md)**
573+
574+
---
575+
223576
## 🏗️ Architecture
224577

225578
<div align="center">

0 commit comments

Comments
 (0)