Ironfish Wasm
Iron Fish WASM package that compiles native Iron Fish code to WebAssembly with TypeScript bindings. This package allows you to use Iron Fish cryptographic functionality in browser extensions, web applications, or any JavaScript environment.
Installation
npm install @ironfish/ironfish-wasm
Features
- Native Iron Fish code compiled to WebAssembly
- TypeScript bindings for better developer experience
- Compatible with browser extensions and web applications
- High-performance cryptographic operations
- Cross-platform compatibility
Usage
import { SaplingKey, Note, AssetIdentifier, UnsignedTransaction } from '@ironfish/ironfish-wasm';
// Generate new keys
const senderKey = SaplingKey.random();
const recipientKey = SaplingKey.random();
// Create a native asset note (IRON)
const note = Note.fromParts(
recipientKey.publicAddress,
BigInt(100), // Amount
"Transfer memo",
AssetIdentifier.native,
senderKey.publicAddress
);
// Create an unsigned transaction
const bytes = new Uint8Array([/* transaction bytes */]);
const unsignedTx = new UnsignedTransaction(bytes);
// Sign the transaction
const signedTx = unsignedTx.sign(senderKey);
// Get transaction details
console.log({
fee: signedTx.fee,
expiration: signedTx.expiration,
outputs: signedTx.outputs.length,
spends: signedTx.spends.length
});
// Export keys as hex for storage
const exportedKey = senderKey.toHex();
// Import key from hex
const importedKey = SaplingKey.fromHex(exportedKey);
Requirements
- Node.js 20.0.0 or higher
- A JavaScript environment with WebAssembly support