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 alpha version of the library by running the following command:
- npm
- Yarn
- pnpm
npm install @iota/audit-trails@latest
yarn add @iota/audit-trails@latest
pnpm add @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:
| Name | Required | Description |
|---|---|---|
IOTA_AUDIT_TRAIL_PKG_ID | yes | Package ID of the deployed IotaAuditTrails Move package |
IOTA_TF_COMPONENTS_PKG_ID | local/custom setups | Package ID of the deployed TfComponents package |
NETWORK_URL | test networks | RPC URL of the IOTA node |
NETWORK_NAME_FAUCET | test networks | Faucet 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.