Using WASM in Applications
Import the WASM entrypoint (@tevm/voltaire/wasm) or a module-specific WASM subpath (@tevm/voltaire/Keccak256/wasm):
@tevm/voltaire/wasm satisfies the same VoltaireAPI contract as @tevm/voltaire and @tevm/voltaire/native. Crypto modules with WASM acceleration (Keccak256, SHA256, Blake2, Ripemd160, Secp256k1, Ed25519, P256, X25519, BN254, EIP712) expose their raw WASM namespace on ._wasm alongside the standard synchronous API.
HDWallet uses native FFI bindings (libwally-core) and is not bundled in @tevm/voltaire/wasm. Import HDWallet from @tevm/voltaire/HDWallet or @tevm/voltaire/native. KZG and Bls12381 fall back to their JS/native implementations because KZG trusted setup tables are large for browser WASM payloads.Build Modes
Build WASM artifacts from the repository root withzig build:
Additional standalone WASM modules built under
wasm/:
wasm/state-manager.wasm— Forked/local EVM state manager forForkProvider({ useWasm: true })wasm/blockchain.wasm— Block storage backend forForkProvider({ useWasm: true })wasm/crypto/*.wasm— Individual crypto modules for size-sensitive builds
WASM Loader Architecture
The internal WASM loader lives atpackages/voltaire-ts/src/wasm-loader/loader.ts (typed by loader.d.ts and types.ts):
- Loads the
.wasmbinary from a filesystem path,URL, orArrayBuffer(supporting both Node.jsfsand browserfetch/WebAssembly.instantiateStreaming). - Manages a bump/free memory interface over WASM linear memory so JavaScript
Uint8Arrayslices are copied safely across the boundary and freed infinallyblocks. - Translates integer C ABI error codes (
0= success, negative = typed error) into Voltaire error classes.
Rust Portable Feature for WASM
Becausewasm32 targets cannot link x86_64/aarch64 assembly (keccak-asm), Cargo.toml switches to pure-Rust portable kernels when compiling crypto_wrappers for WASM:
Bundler Configuration
- Vite
- Webpack 5
Testing WASM Parity
Run the WASM tests with Vitest to verify byte-for-byte parity between WASM and JS/native outputs:Related
- Build System — Zig WASM targets and optimization flags
- Multi-Language Integration — How
c_api.zigpowers both WASM and native FFI - Testing — Cross-validating JS, WASM, and native outputs

