WASM (WebAssembly)
Parameters
| Parameter | Value |
|---|---|
| Architecture | Stack |
| Word size | 64-bit (i64), 32-bit (i32) |
| Hash function | -- (runtime-dependent) |
| Digest width | 32 bytes |
| Stack depth | Operand stack (unlimited, bounded by metering) |
| Output format | .wasm |
| Cost model | Gas, cycles, or wall-clock (OS-dependent) |
WASM is a VM, not an OS. One .wasm binary runs on multiple OSes — only
the runtime binding differs.
Operating Systems Running WASM
| OS | Runtime | Binding | Notes |
|---|---|---|---|
| Near Protocol | nearcore | os.near.* |
1 contract per account, promise-based async |
| Cosmos (100+ chains) | CosmWasm / wasmd | os.cosmwasm.* |
IBC cross-chain, typed entry points |
| Arbitrum | Stylus (ArbOS) | os.arbitrum.* |
WASM + EVM coexistence, EVM-compatible gas |
| Icp | Canister runtime | os.icp.* |
Deterministic time slicing, persistent memory |
| WASI | wasmtime / wasmer | os.wasi.* |
Filesystem, clock, random (planned) |
| Browser | JS runtime | os.browser.* |
DOM, fetch, Web APIs (planned) |
Lowering
All WASM OSes share the same WasmLowering path:
TIR → WasmLowering → WASM module (.wasm)
The WASM bytecode is identical. What differs is:
- Host functions — each OS provides different imports (storage, messaging, crypto, filesystem)
- Entry points — Near uses
#[near]attributes, CosmWasm usesinstantiate/execute/query, Stylus uses Solidity ABI, Icp uses#[update]/#[query], WASI uses_start - Metering — Near and Cosmos use gas, Icp uses cycles, Stylus uses EVM-compatible gas, WASI uses wall-clock
The runtime binding (os.<os>.*) handles these differences. The compiler
produces one WASM module; the linker injects the correct host function
imports for the target OS.
Cost Model (OS-dependent)
WASM itself has no built-in metering — cost is imposed by the OS runtime.
| OS | Cost unit | Notes |
|---|---|---|
| Near | Gas | Per-instruction (1 gas ≈ 1 opcode) |
| Cosmos | Gas | Per-instruction + storage |
| Arbitrum (Stylus) | Gas | EVM-compatible gas metering |
| ICP | Cycles | Deterministic time slicing |
| WASI | Wall-clock | No metering (direct execution) |
| Browser | Wall-clock | No metering (direct execution) |
Detailed per-instruction cost model planned per OS.