Getting Started with Node.js
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.
Requirement | Version |
---|---|
Node.js | 14.x, 16.x, or 18.x - LTS |
Your package manager of choice | npm 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
- Yarn
npm i @iota/wallet@1.0.17
yarn install @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:
- Clone the repository:
git clone git@github.com:iotaledger/wallet.rs.git
- Move into the project's directory:
cd wallet.rs
- Checkout the
production
branch, or any1.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:
- Move into the Node.js binding directory:
cd bindings/nodejs
- Install the dependencies with your package manager of choice:
- npm
- Yarn
npm i
yarn
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
- Yarn
npm run install
yarn install
Use the Library
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.
You can find more examples using the wallet.rs
library's node.js binding in the examples section.
loading...