What is a hexadecimal message type in sending transaction

Reading the documentation and data about sending transactions I saw that there are 2 types of messages:

type 1 is plain,
type 2 is secure (encrypted)

Here is the example of transaction with type 1 message I am not sure but I believe this is the transaction with the type 2 message

Now looking at the official NEM wallet it looks like there is also a hexadecimal type:

What is this type? I know what hexadecimal means and can guess what it can mean but I would like to see a documentation reference or official explanation.

How can I send a message to another Ethereum address? And how would that user receiving know that its a message? Is there an Ethereum wallet that will show that I sent a message to that address? And what is the max size I can send?

@CryptoInfo you should ask this question on Ethereum forum :wink:

You can’t send directly message/transaction from NEM to Ethereum blockchain right now. If you want send a message from Ethereum to Ethereum address best place is ask on some Ethereum forum.

@nem_curious

Unencrypted message is also send as hexadecimal string to API (mostly is called some UTF8toHEX function as in nanowallet). When you put message:

  • “test” is converted to “74657374” in hex string
  • “1234” is converted to “31323334” in hex string

Hexadecimal message type is a little bit different. User message is already hexadecimal string so it’s no need convert it to hex.
That’s why it allows you to put 2046 (2048 - 2) signs instead 1024bytes (signs) like in simple unencrypted message. Why -2? Because each hexadecimal message has prefix ‘fe’ to tell how it should be decrypted.

Decrypt algorithm (for unencrypted message):
if (it starts with ‘fe’)
remove ‘fe’ from beginning and rest is hexadecimal type message (no need to decrypt hextoutf8)
else
convert hexToUtf8

Example transactions and difference between unencrypted and hexadecimal:

Unencrypted with message “1234” (payload is “31323334”):
http://192.3.61.243:7890/transaction/get?hash=aa655b6c9828b667e64a6194e2e52b2aa715a4fc758de152edc630971a6e6f42

Hexadecimal with message “1234” (payload is “fe1234”):
http://192.3.61.243:7890/transaction/get?hash=40e61876c107a258c3cfcebb54590fe468b5f54f11d032eee133003bdf8c3bf3

So hexadecimal type is designed to send hex string directly (it allows you send more signs because you already sending hex). I guess this is main (only?) reason. @BloodyRookie, @gimre, @Jaguar0625 can confirm or not :slight_smile:

4 Likes

Maybe you could try Interledger to communicate NEM with Ethereum.
Interledger is an open protocol suite for sending payments across different ledgers.

@CryptoBeliever thank you very much for a very good explanation. So if I understood it correctly, all the time I am getting an information about the unencrypted transaction via the API I am getting a “hex encoded string” in a payload which I can ‘unhex’.

If the transaction payload starts with ‘fe’, no need to unencode it.

When I see a transaction in the blockexplorer, the message is already unencoded and the actual payload is 77656c636f6d6520746f207368656c74657264616f21.

One question is left. Is it possible to have a payload which starts with ‘fe’ which is not a hexadecimal string? If I want to send a string like “þÿ” it will be encoded to “feff” and then it will not be clear whether it is hexadecimal “ff” was sent or my “þÿ”.


As a suggestion, it would be nice to add this information to a documentation.

Yes, that is the reason.

1 Like

@nem_curious
Yes payload returned by API is “hex encoded string”. If starts with ‘fe’ you just remove it and it’s decded + it’s type hexadecimal. In explorer it’s already decoded.

About þ it will be no problem in nanowallet because nano first use rstr2utf8 function which “Converts a raw javascript string into a string of single byte characters using utf8 encoding.” So it changes þ to two single bytes characters.

If it would no rstr2utf8 then indeed it would be problem if message will start with þ. For example I remove rstr2utf8 conversion and provided message þaaa. Now it’s wrong interpreted by explorer as HEX:

http://bob.nem.ninja:8765/#/transfer/d0d80a73c2ac5e055f1f4f10c08302e85575c817487c95827db787f6d4a7863a

because payload starts with ‘fe’

http://192.3.61.243:7890/transaction/get?hash=d0d80a73c2ac5e055f1f4f10c08302e85575c817487c95827db787f6d4a7863a

One more time thanks @CryptoBeliever. Probably the last question here, is payload for the message always in lowercase hex? Can I see something like “FE616161”?

@nem_curious by API it will be returned always lowercase.

Very nice explanation

(not sure if nano allows this right now, but you should also be able to combine hex input with encryption)

1 Like

@gimre you have one-option choice {unencrypted, encrypted, hexadecimal} in nanowallet. So currently it doesn’t allow you to send encrypted hexadecimal message.