Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generating IOTA addresses from a seed: API call Get_new_addresses()
// The snippet is a part of the IOTA Developer Essentials project. You can reach it at
// Complete description and story behind the snippet is available at:
// Requirement: A core module of IOTA Javascript Library (!npm install @iota/core)
var iotalib = require('@iota/core');
var NodeURL = "";
var iota = iotalib.composeAPI({
'provider': NodeURL
//Let's generate 3 addresses using default security level=2.
//It is a deterministic function - it always generates same addresses as long as the Seed, Security Level and Index are the same
//In case of iota.js library, it additionally checks generated addresses against the Tangle whether the address was spent from
//So the following snippet leverages also API calls against a node
//Please also note that generating addresses can take quite long
var promise = iota.getNewAddress(MySeed, { index: 0, total: 3, returnAll: true } )
.then(address => {
console.log(address); //returned addresses are printed out
.catch(error => {
console.log("Error occured: %s", error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment