Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Validating IOTA address
// 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#C65223B0864A
// Requirement: IOTA Javascript Library (!npm install iota.lib.js)
var IOTA = require('../../node_modules/iota.lib.js/lib/iota');
var NodeURL = "https://nodes.thetangle.org:443";
var iota = new IOTA({
'provider': NodeURL
});
//address including checksum
var InputAddr = "CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RWTHBIRSXTA";
if (!iota.valid.isAddress(InputAddr) || InputAddr.length!=90) {
console.log("Not valid input address given.");
} else {
console.log("Input address incl checksum:");
console.log(InputAddr);
console.log("Is it valid addr based on checksum? %s", iota.utils.isValidChecksum(InputAddr));
console.log("Input address excl checksum:");
console.log(iota.utils.noChecksum(InputAddr))
}
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.