Getting Started with Wasm
Getting Started with Wasm
Minimum Requirements
- Node.js (>=
v20
)
Install the Library
If your project does not contain it already, install the peer dependency @iota/iota-sdk
as well.
- npm
- Yarn
- pnpm
npm install @iota/iota-sdk
yarn add @iota/iota-sdk
pnpm add @iota/iota-sdk
You can install the latest beta version of the library by running the following command:
- npm
- Yarn
- pnpm
npm install @iota/hierarchies@alpha
yarn add @iota/hierarchies@alpha
pnpm add @iota/hierarchies@alpha
Build the Library
Alternatively, you can build the bindings to work with currently unreleased features. You can find instructions for this in the hierarchies
repository.
Usage in Node.js and Web
The Wasm packages are bundled for both Node.js and web. To use them, you must import them from the correct entry point:
- Node.js
import { ... } from '@iota/hierarchies/node';
- Web
import { ... } from '@iota/hierarchies/web';
Usage Examples
- Typescript (Node.js)
- Typescript (Web)
bindings/wasm/hierarchies_wasm/examples/src/01_create_federation.ts
loading...
import { Federation } from "@iota/hierarchies/web";
import assert from "assert";
import { getFundedClient } from "./util";
export async function createFederation(): Promise<void> {
const hierarchies = await getFundedClient();
const { output: federation }: { output: Federation } = await hierarchies.createNewFederation().buildAndExecute(
hierarchies,
);
console.log("\n✅ Federation created successfully!");
console.log("Federation ID: ", federation.id);
assert(federation.id, "Federation ID should not be empty");
assert(federation.rootAuthorities.length > 0, "Federation should have at least one root authority");
}
See utils for details about the implementations about the helper functions used here.