Skip to content

Instantly share code, notes, and snippets.

@cyclux
Created December 28, 2017 13:22
Show Gist options
  • Save cyclux/cecf914aef9d1bb24a9ec3b370c5aec3 to your computer and use it in GitHub Desktop.
Save cyclux/cecf914aef9d1bb24a9ec3b370c5aec3 to your computer and use it in GitHub Desktop.
Generate IOTA addresses
'use strict';
var IOTA;
IOTA = require('./iota.lib.js/lib/iota');
// Get values from CLI parameters
var index_start = parseInt(process.argv[2]);
var amountOfAddresses = process.argv[3];
var seed = process.argv[4];
var iotajs = new IOTA({
'host': 'http://localhost',
'port': '14265'
});
function generateAddresses(seed, index_start) {
if (!amountOfAddresses){
amountOfAddresses = 20;
}
console.log('Generating ' + amountOfAddresses + ' addresses (start: ' + index_start + ')..');
iotajs.api.getNewAddress(seed, {'index': index_start,'checksum': true, 'total': amountOfAddresses, 'security': 2, 'returnAll': true}, function(_, addresses) {
console.log('SEED: ' + seed);
var iter = -1;
addresses.map(function(address){
iter += 1;
console.log('#' + iter + ' | ' + address);
});
console.log('Successfully created new addresses!');
});
}
generateAddresses(seed, index_start);
@cyclux
Copy link
Author

cyclux commented Dec 28, 2017

Example:
node generate_addresses.js 0 100 YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9YOUR9SEED9Y
0 -> index start (default is 0)
100 -> index end (generate until this index )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment