How blocklessnetwork/sdk-rust works
Project type and purpose
• This is a Rust SDK crate (blockless-sdk-rust) designed for building WebAssembly modules that run on the Blockless network (native or browser runtimes).
• It provides abstractions over host-provided services (HTTP, socket/CGI, memory, LLM) so that example applications (under examples/) can be compiled to wasm32-wasip1 and executed in the Blockless runtime environment.
File structure
• Top‐level files:
• Cargo.toml, rust-toolchain.toml – project metadata and toolchain lock
• Makefile – build helper
• .github/workflows/* – CI for build/test/publish
• src/ contains the library source, split into modules:
• lib.rs – crate root, exposes public API
• http.rs – HTTP client abstraction
• socket.rs & cgi.rs – socket/CGI interfaces
• memory.rs – persistent storage interface
• llm.rs – LLM / Model Control Protocol interface
• error.rs – error types
• examples/ – sample applications that use the SDK modules and demonstrate runtime integration.
README for additional insights
• Usage examples build to WASM and invoke:
• Blockless runtime → loads WASM → grants permissions (HTTP, SSE, etc.)
• SDK APIs → call host functions → return data to the module.
• Demonstrates multiple host services (Coingecko HTTP, HTTPBin, LLM/MCP).
Main components
A. Developer Code & Examples
• Your application code (e.g., examples/httpbin.rs)
• Links against blockless-sdk crate
B. blockless-sdk Library
• Modules: HTTP, Socket/CGI, Memory, LLM, Error
• Compiled into a single WASM binary
C. Blockless Runtime (Host Environment)
• Provides low-level host functions (imports) to:
• Perform HTTP requests
• Open sockets / CGI streams
• Read/write to persistent memory
• To LLM endpoints via SSE
• Enforces permissions (via CLI flags)
D. External Services
• HTTP endpoints (e.g., https://api.coingecko.com/, httpbin.org)
• LLM tool servers (port 3001/3002 for MCP)
E. Crate Publishing & CI/CD
• GitHub Actions workflows: CI (build/test), publish to crates.io
• Developer → pushes tag → publish.yaml → crates.io
Relationships & interactions
1. Developer writes Rust code (examples) → imports SDK
2. cargo build --target wasm32-wasip1 → WASM module
3. Blockless runtime CLI (bls-runtime or browser plugin) loads WASM
4. WASM → calls imported host functions (HTTP, socket, memory, LLM)
5. Host functions → forward to external services → return data
6. WASM module processes data & returns results to the runtime → console or caller.
Architectural patterns & design principles
• Modular crate: each service has its own Rust module
• WASM host-guest boundary: clear separation between SDK (guest) and runtime (host)
• Permission model: runtime enforces fine-grained access
• Example‐driven: showcases extensibility and how the SDK integrates new host services.
Final recommendations
• WASM target artifact in your build pipeline.
• Core architectural boundary: SDK crate vs. Blockless runtime vs. external world.