IOTA Trytes
The IOTA distributed ledger operates on ternary messages. These types of messages are represented by trits {-1,0,1}, and which is a base-3 numbering system. Within IOTA we also have the concept of a tryte which is 3 trits and which can represent 27 states. These states are then named with uppercase letters (A-Z) and the "9". The message "Hello", for example, is translated into the trytes of "RBTC9D9DCD" [code]:
Input (Text) | |
---|---|
Input (Trytes) | |
Method |
|
Result |
Example
The example given on the IOTA Github for the conversion of ASCII to trytes is:
2 Trytes === 1 Byte There are a total of 27 different tryte values: 9ABCDEFGHIJKLMNOPQRSTUVWXYZ // 1. We get the decimal value of an individual ASCII character 2. From the decimal value, we then derive the two tryte values by basically calculating the tryte equivalent (e.g. 100 === 19 + 3 * 27) a. The first tryte value is the decimal value modulo 27 (27 trytes) b. The second value is the remainder (decimal value - first value), divided by 27 3. The two values returned from Step 2. are then input as indices into the available values list ('9ABCDEFGHIJKLMNOPQRSTUVWXYZ') to get the correct tryte value // EXAMPLES Lets say we want to convert the ASCII character "Z". 1. 'Z' has a decimal value of 90. 2. 90 can be represented as 9 + 3 * 27. To make it simpler: a. First value: 90 modulo 27 is 9. This is now our first value b. Second value: (90 - 9) / 27 is 3. This is our second value. 3. Our two values are now 9 and 3. To get the tryte value now we simply insert it as indices into '9ABCDEFGHIJKLMNOPQRSTUVWXYZ' a. The first tryte value is '9ABCDEFGHIJKLMNOPQRSTUVWXYZ'[9] === "I" b. The second tryte value is '9ABCDEFGHIJKLMNOPQRSTUVWXYZ'[3] === "C" Our tryte pair is "IC" // RESULT: The ASCII char "Z" is represented as "IC" in trytes.