Skip to main content

Getting Started with WASM/TypeScript

Alpha Software

The IOTA SDK is currently in alpha. APIs, interfaces, and behavior may change without notice between releases. It is not yet recommended for production use.

The IOTA SDK WASM bindings allow JavaScript and TypeScript developers to use the SDK in Node.js and the browser. The core Rust SDK is compiled to WebAssembly, and the package ships with a TypeScript API and type declarations.

TypeScript SDK

If you are building a web dApp, also consider the IOTA TypeScript SDK, a native TypeScript implementation with React tooling (dApp Kit). The WASM bindings expose the same API surface as the other IOTA SDK bindings, which makes them a good fit if you want identical behavior across languages.

Prerequisites

Before using the WASM bindings, ensure you have:

  • Node.js: Version 20 or higher (for Node.js usage), or a browser with WebAssembly support.

Installation

Add the IOTA SDK to your project using your package manager:

npm install @iota/[email protected]

The package contains the compiled WebAssembly binary and TypeScript declarations, so no Rust toolchain is required.

Quick Start Example

The following example demonstrates how to connect to the IOTA Testnet and retrieve the Chain ID.

1. Create a chain_id.mjs file

Create a new file named chain_id.mjs and paste the following code. The WASM module must be initialized with initAsync() before any other call:

bindings/wasm/examples/chain_id.mjs
loading...

2. Run the code

In your terminal, run:

node chain_id.mjs

Usage in the Browser

The same API works in the browser. See the browser example for a complete HTML page that loads the WASM module and queries the chain ID.

What's Next?

Now that you have connected to the network, you can explore more advanced features:

  • Accounts and Addresses: create a mnemonic, derive addresses, and check coin balances.
  • Transactions: build, sign, and send Programmable Transaction Blocks (PTBs), including staking and reusing command results.
  • Queries: query owned objects, events, and transactions with the GraphQL client.

View more comprehensive examples in the official WASM examples directory.