Skip to content

Instantly share code, notes, and snippets.

Embed
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 https://hribek25.github.io/IOTA101/
// Complete description and story behind the snippet is available at: https://hribek25.github.io/IOTA101/Allchapters_javascript.ipynb.html#0FF479CB6C0A
// Requirement: IOTA Javascript Library (!npm install iota.lib.js)
var IOTA = require('../../node_modules/iota.lib.js/lib/iota');
//For this particular task the Node URL is not important as it will not be contacted at all
//However it has to be well - formatted URI
var NodeURL = "https://nodes.thetangle.org:443";
var MySeed = "WKQDUZTGFKSSLACUCHHLZRKZBHSDSCEBHKUPDLKFBQALEBKDMFRPUQGZRXAADPG9TSRTZGGBZOFRJCFMM";
var iota = new IOTA({
'provider': NodeURL
});
//Let's generate 3 addresses using default security level=2.
//It is deterministic function - it always generates same addresses as long as the Seed, Security Level and Index are the same
// Please note, it is async method - result is returned via callback function
iota.api.getNewAddress(MySeed,
{ "index": 0, "total": 3, "security": 2 },
function (error, success) {
if (error) {
console.log("Error occured: %s", error);
} else {
console.log();
console.log(success); //returned addresses are printed out
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.