Skip to main content
Version: IOTA

Getting Started with Node.js

note

You can find a guide for exchanges and the most common use cases in the Chrysalis documentation, which is based on wallet.rs and Node.js.

The IOTA Wallet Node.js binding is published on npmjs.com.

The code examples use dotenv for password management.

Requirements

You can use the following links to install any of the requirements.

RequirementVersion
Node.js14.x, 16.x, or 18.x - LTS
Your package manager of choicenpm or Yarn

Install the Library

Since wallet.rs is also used to communicate with nodes in the Shimmer network that runs the Stardust protocol, if you plan to use the library in the IOTA network with the Chrysalis protocol, you will need to install the latest 1.x.x version.

npm i @iota/wallet@1.0.17

Build the Library

If you prefer, you can build the library from source instead of installing it. This process is more complex than simply installing the library.

Clone the Repository

The first thing you will need to build the library from source is:

  1. Clone the repository:
git clone git@github.com:iotaledger/wallet.rs.git
  1. Move into the project's directory:
cd wallet.rs
  1. Checkout the production branch, or any 1.x.x tag:
git checkout production

Install the Library's Dependencies

Once you have cloned the repository, you can proceed to install the library's dependencies:

  1. Move into the Node.js binding directory:
cd bindings/nodejs
  1. Install the dependencies with your package manager of choice:
npm i

Build the Library

Once you have installed the library's dependencies, you can proceed to install the library. The install script will install any necessary dependencies and then proceed to build the library and create the necessary packages.

npm run install

Use the Library

Safe password Storage

In a production setup, do not store passwords in the host's environment variables or in the source code. For reference, see our backup and security recommendations for production setups.

To use the library, you simply need to create an AccountManager from the @iota/wallet package in your application as shown in the example on line 8 of the example below.

More Examples

You can find more examples using the wallet.rs library's node.js binding in the examples section.

bindings/nodejs/examples/binding_examples/1-create-account.js
loading...