TronRelic > Tools > TronMoji Generator

TronMoji Generator

Click on the grid to create a TronMoji. The TronMoji is a 16x16 pixel image, and each pixel can be one of 16 colors (0-15). The color is represented by a single hex digit. For example, to create a TronMoji with the first row as red, green, blue, and yellow, enter f6b4 in the TronMoji Hex input field.

Once you have created your TronMoji, you can send it to another address by entering the address in the "To Address" field and clicking the "Send TronMoji" button. The TronMoji will be sent as a memo in the transaction. See the Original TronMoji Site.

Color Key

Connect TronLink Pro to enable sending TronMoji

A TronMoji is a pixel-based image represented by a hexadecimal string. This string is written to the TRX transaction memo field. Below are the technical details on how a TronMoji image is constructed and interpreted by code:

1. TronMoji Hexadecimal String
  • The TronMoji image is encoded as a hexadecimal string.
  • Each character in the string represents a color value for a single pixel and occupies a half byte.
  • The hexadecimal string is 256 pixels, 128 bytes, and 256 hexadecimal characters long. Each byte is 2 hexadecimal characters.
  • The hexadecimal string is always prepended with the prefix `tronmoji:` in the memo field. This brings the total bytes to 137.
2. Color Encoding

The color of each pixel is represented by a single hexadecimal digit (0-9, a-f).

The color values are mapped as follows:

  • `0`: Transparent
  • `1`: Black
  • `2`: White
  • `3-f`: Various colors in the HSL color space, calculated as `hsl((value - 2) * 27.6923, 100%, 50%)`.
3. Grid Dimensions

The grid dimensions (number of pixels in X and Y directions) are assumed to be 16x16.

Example: A 16x16 grid would have 256 pixels, requiring a 256-character hexadecimal string, prepended with 18-character hexadecimal string of 'tronmoji:', totaling 274 hexadecimal characters (274/2, 137 bytes).

4. UTF8 Violations

TronMojis violate UTF8 encoding, and as such must be written into both the memo and raw_hex fields manually.

When using TronWeb to create a transaction with a memo (stored in transaction.raw_data.data), the transaction.raw_data_hex representation of the transaction will include some prepended bytes before the actual memo data. These bytes are Protobuf encoding metadata, and they follow Protocol Buffers (ProtoBuf) varint encoding rules.

  • Field Number and Wire Type
    • The first byte indicates the field number and wire type.
    • In Protobuf, a field is encoded as: (Field Number << 3) | Wire Type.
    • The memo's field number is 6, and the wire type for bytes is 2.
    • Thus, the first byte is: (6 << 3) | 2 = 0x32.
    • 6 << 3 shifts the field number left by 3 bits (0b00110000 or 0x30).
    • OR-ing with 0b00000010 (wire type 2 for length-delimited fields) results in 0x32.
  • Length of the Memo (Varint-Encoded)
    • The next byte(s) indicate the length of the memo string in bytes.
    • This is encoded as a varint (a flexible-length encoding for small integers).
    • If the memo is short (≤127 bytes), this is just 1 byte.
    • If the memo is longer, multiple bytes are used (continuation bit set for values ≥ 128).

* For clarification: The memo field is 256 bytes, which would contain 512 individual hex 'characters' (0-f).