IOTA Identity Stronghold Node.js
This is the beta version of the official Stronghold Account Storage plugin for Node.js with IOTA Identity Wasm.
Install the plugin:
Latest Release: this version matches the main branch of this repository and is stable.
npm install @iota/identity-stronghold-nodejs
Development Release: this version matches the dev branch of this repository, may see frequent breaking changes and has the latest code changes.
npm install @iota/identity-stronghold-nodejs@dev
Usage
const { AccountBuilder, ExplorerUrl } = require('@iota/identity-wasm/node')
const { Stronghold } = require('@iota/identity-stronghold-nodejs')
async function main() {
const filepath = "./example-strong.hodl";
const password = "my-password";
const stronghold = await Stronghold.build(filepath, password);
let builder = new AccountBuilder({
storage: stronghold,
});
let account = await builder.createIdentity();
const did = account.did();
console.log(did.toString());
const document = account.document();
console.log(JSON.stringify(document, null, 2));
console.log(`Explorer URL:`, ExplorerUrl.mainnet().resolverUrl(did));
}
main()
Build
Alternatively, you can build the bindings if you have Rust installed. If not, refer to rustup.rs for the installation. Then install the necessary dependencies using:
npm install
To use the latest local changes from the Wasm bindings follow the build instructions from the IOTA Identity Wasm build section and then link the result with:
cd ../wasm
npm link
cd ../stronghold-nodejs
npm link @iota/identity-wasm
and then build the bindings
npm run build
If you linked the Wasm bindings, don't forget to unlink before packaging the module.
npm unlink --no-save @iota/identity-wasm
npm install
Minimum Requirements
The minimum supported version for node is: v16.0.0