Try it Live
Run FeeMarket examples in the interactive playground
FeeMarket WASM
WASM implementation status for fee market calculations.Status
WASM NOT IMPLEMENTED (and not needed)Why No WASM?
FeeMarket provides:- EIP-1559 and EIP-4844 constants (no computation)
- Simple bigint arithmetic (base fee, blob fee formulas)
- Lightweight validation functions
- Already optimal in TypeScript
- Too lightweight for WASM overhead to provide benefit
- Pure calculations with no I/O or complex state
less than 1μs)
Performance Characteristics
Pure TypeScript benchmarks:- Function call: ~1-2μs
- Memory copy: Additional overhead for bigint conversions
- Total: 10-100x slower for these operations
When WASM Would Help
WASM beneficial for:- Heavy computation (greater than 10μs per operation)
- Cryptographic operations (hashing, signatures, elliptic curve)
- Large data processing (RLP encoding, ABI encoding)
- Batch operations (processing thousands of items)
- CPU-intensive loops
- Lightweight bigint math
- Simple formulas
- No cryptographic operations
- Typically single-item operations
Implementation Status
FeeMarket.wasm.ts
Re-exports pure TypeScript implementation:Usage
Simply use FeeMarket.js directly:.wasm.js:
Benchmarks
Run benchmarks to verify performance:BaseFee: ~4M ops/secBlobBaseFee: ~100K ops/sec (Taylor series)calculateTxFee: ~20M ops/secnextState: ~2M ops/sec
fee-market-bench-results.json for detailed results.
Alternative: Zig Implementation
Fee market calculations implemented in Zig (fee_market.zig) for:
- Testing compatibility
- Native performance validation
- Reference implementation
- V8 JIT optimizes bigint arithmetic effectively
- Zig-WASM bridge adds overhead
- No performance gain for simple calculations
- Native CLI tools
- Testing against reference implementation
- Educational purposes
Comparison with Other Primitives
FeeMarket similar to Uint256: pure bigint math, no WASM benefit.
Future Considerations
WASM implementation reconsidered if:- Batch operations common (thousands of fee calculations)
- Integration with other WASM modules (shared memory)
- Platform with poor bigint performance
References
- FeeMarket.bench.ts - Performance benchmarks
- fee_market.zig - Zig reference implementation
- branded-feemarket.mdx - TypeScript implementation

