Skip to content

Instantly share code, notes, and snippets.

@Hribek25
Last active September 24, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hribek25/a8568d529d17bdd2a86f8ca1340d32e8 to your computer and use it in GitHub Desktop.
Save Hribek25/a8568d529d17bdd2a86f8ca1340d32e8 to your computer and use it in GitHub Desktop.
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: A checksum module of IOTA Javascript Library (!npm install @iota/checksum)
var iotalib = require('@iota/checksum'); //this package is also useful when validating an address
//some IOTA address
var Adr = "CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RW";
console.log("Original input excl. checksum address:");
console.log(Adr);
console.log("Length: %s", Adr.length)
var AdrInclCheckSum = iotalib.addChecksum(Adr); //generate checksum for the given address
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