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/notarization@alpha
yarn add @iota/notarization@alpha
pnpm add @iota/notarization@alpha
Build the Library
Alternatively, you can build the bindings to work with currently unreleased features. You can find instructions for this in the notarization
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/notarization/node';
Web
import { ... } from '@iota/notarization/web';
Usage Examples
- Typescript (Node.js)
- Typescript (Web)
The following code creates a new IOTA Notarization suitable for publishing to a locally running test network.
loading...
The following code creates a new IOTA Notarization suitable for publishing to a locally running test network.
import { TimeLock } from "@iota/notarization/web";
import { strict as assert } from "assert";
import { getFundedClient } from "./util";
/** Demonstrate how to create a Locked Notarization and publish it. */
export async function createLocked(): Promise<void> {
console.log("Creating a simple locked notarization example");
// create a new client that offers notarization related functions
const notarizationClient = await getFundedClient();
// Calculate an unlock time (24 hours from now) to be used for deleteLock
const delete_unlock_at = Math.round(Date.now() / 1000 + 86400); // 24 hours
const utf8Encode = new TextEncoder();
// ... Rest of the code
}
See utils for details about the implementations about the helper functions used here.