Skip to main content

Getting Started with Wasm

Minimum Requirements

Install the Library

If your project does not contain it already, install the peer dependency @iota/iota-sdk as well.

npm install @iota/iota-sdk

You can install the latest alpha version of the library by running the following command:

npm install @iota/audit-trails@latest

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/audit-trails/node';

Web

import { ... } from '@iota/audit-trails/web';

Usage Examples

This sections gives a brief description how to run the provided examples. The Examples README for further details including a list of provided examples.

Prerequisites

Before running the examples, complete the Local Network Setup to start a local IOTA node and deploy the Audit Trails package.

Environment Variables

Set the following environment variables:

NameRequiredDescription
IOTA_AUDIT_TRAIL_PKG_IDyesPackage ID of the deployed IotaAuditTrails Move package
IOTA_TF_COMPONENTS_PKG_IDlocal/custom setupsPackage ID of the deployed TfComponents package
NETWORK_URLtest networksRPC URL of the IOTA node
NETWORK_NAME_FAUCETtest networksFaucet alias used by @iota/iota-sdk

Running an Example

Clone the repository, install dependencies, and run any example by name:

git clone https://github.com/iotaledger/notarization.git
cd notarization/bindings/wasm/audit_trail_wasm
npm install
npm run build
# If not having published the package to localnet, you can alternatively run `eval $(./audit-trail-move/scripts/publish_package.sh)`
# instead of setting the environment variables manually.
export IOTA_AUDIT_TRAIL_PKG_ID=<audit-trail-pkg-id goes here>
export IOTA_TF_COMPONENTS_PKG_ID=<tf-components-pkg-id goes here>
npm run example:node -- 01_create_audit_trail

See utils for details about the helper functions used in these examples.

API Reference

For complete API documentation, see the WASM API Reference.