Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Conversion: trytes and trits
// 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#3BB8C879CCAE
// Requirement: IOTA Javascript Library (!npm install iota.lib.js)
var Converter = require('../../node_modules/iota.lib.js/lib/crypto/converter/converter') //loading helping converter functions of iota.lib.js library
var Trytes = "YZJEATEQ9JKLZ" //some data encoded in Trytes
console.log(Trytes)
console.log("Number of Trytes: %s" , Trytes.length)
var Trits = Converter.trits(Trytes) //converting Trytes to Trits
console.log(Trits.join(","))
console.log("Number of trits: %s", Trits.length) //Number of trits is three times the number of trytes obviously
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.