Instantly share code, notes, and snippets.

Embed
What would you like to do?
IOTA address and checksum
// 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#39B011574CF0
// Requirement: IOTA Javascript Library (!npm install iota.lib.js)
var IOTA = require('../../node_modules/iota.lib.js/lib/iota');
var NodeURL = "https://field.deviota.com:443";
var iota = new IOTA({
'provider': NodeURL
});
//some IOTA address
var Adr = "CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RW";
console.log("Original input excl. checksum address:");
console.log(Adr);
console.log("Length: %s", Adr.length)
var AdrInclCheckSum = iota.utils.addChecksum(Adr); //generate checksum
console.log("Input address including checksum:")
console.log(AdrInclCheckSum) // the last 9 trytes is the checksum
console.log("Length incl checksum: %s", AdrInclCheckSum.length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment