StarForge core functionality compiled to WebAssembly for browser execution, enabling web-based IDEs and development environments.
- Rust 1.70+ with
wasm32-unknown-unknowntarget - wasm-pack 1.3+
- Node.js 16+
- npm or yarn
rustup target add wasm32-unknown-unknown# macOS
brew install wasm-pack
# Linux
curl https://rustwasm.org/wasm-pack/installer/init.sh -sSf | sh
# Windows (with npm)
npm install -g wasm-packcd wasm
wasm-pack build --target web --devOutput: pkg/ directory with .wasm and .js files
cd wasm
wasm-pack build --target web --releaseSize: ~100-200KB minified + gzipped
cd wasm
python3 -m http.server 8000
# OR
npm run serveVisit: http://localhost:8000
- Generate keypairs
- Create/manage wallets
- Validate public keys
- Track balances
- SHA256 hashing
- Random generation
- Base64 encoding/decoding
- Hex validation
- localStorage integration
- Config persistence
- Session management
- Fetch account details
- Get balances
- Submit transactions (async)
- Validate contract IDs
- Format inspection
- Compatibility checks
import init, {
WasmKeypair,
WasmWallet,
WasmCrypto,
} from "./pkg/starforge_wasm.js";
await init();
// Generate keypair
const keypair = WasmKeypair.generate();
console.log(keypair.public_key());
// Create wallet
const wallet = new WasmWallet(pubkey, "testnet");
wallet.set_balance(100);
// Hash
const hash = WasmCrypto.sha256("hello");
console.log(hash);
// Validate
const valid = WasmKeypair.validate_public_key("G...");Built-in web IDE with:
- Wallet Tab: Generate, create, manage wallets
- Crypto Tab: Hash, encode/decode, generate random
- Contract Tab: Validate contract IDs, inspect
Access at: http://localhost:8000/index.html
| Operation | Time |
|---|---|
| Keypair generation | ~5ms |
| SHA256 hash | ~1ms |
| Random generation | ~0.5ms |
| Base64 encode/decode | ~2ms |
| Validation | <1ms |
-
Build for production:
wasm-pack build --target web --release
-
Copy
pkg/to hosting static files -
Serve
index.html
FROM node:18-alpine
WORKDIR /app
COPY wasm/ .
RUN npm install -g wasm-pack
RUN wasm-pack build --target web --release
EXPOSE 8000
CMD ["npx", "http-server", "-p", "8000"]Upload to CDN:
wasm-pack build --target bundler
# Use with webpack/rollup| Build | Size | Gzipped |
|---|---|---|
| Dev | 350KB | 80KB |
| Release | 180KB | 45KB |
| Release + Strip | 120KB | 30KB |
- ✅ Chrome 74+
- ✅ Firefox 79+
- ✅ Safari 14.1+
- ✅ Edge 74+
⚠️ Mobile browsers (90%+ support)
- WASM runs in browser sandbox
- No access to filesystem by default
- localStorage is client-side only
- Use HTTPS for production
- Validate all user inputs
- Never store secrets in localStorage
wasm-pack test --headless --firefox- Generate keypairs in browser
- Validate public keys
- Hash strings
- Encode/decode base64
npm install -g wasm-packcargo clean
wasm-pack build --target web- Check browser console (F12)
- Verify WASM module loaded
- Check module paths in HTML
- Use
--releaseflag - Enable minification
- Use tree-shaking bundler
- Smart contract compilation
- Transaction builder UI
- Multi-sig support
- Hardware wallet integration
- Advanced contract inspection
- Template preview
generate()→ keypairpublic_key()→ stringvalidate_public_key(key)→ boolvalidate_contract_id(id)→ bool
new(pubkey, network)→ walletpublic_key()→ stringbalance()→ f64set_balance(amount)→ void
sha256(input)→ stringrandom_hex(length)→ stringto_base64(input)→ stringfrom_base64(input)→ stringis_valid_hex(input)→ bool
new()→ configget(key)→ string | nullset(key, value)→ voidload_from_storage(key)→ configsave_to_storage(key)→ void
new(network)→ clientget_account(id)→ Promiseget_balance(id)→ Promisesubmit_transaction(tx)→ Promise