NEM Api - Ability to save data [SOLVED]

Hi, I’m looking into NEM and trying to determine if there is any way data can be saved in objects.
I’ve noticed a message field in a transaction but can’t find the limit to it.
Does a transaction have to transfer mosaic or xem between two account or can it be used to save the message?

Are most people who are developing dapps using the message field to store a hash to the data stored on another platform or am i missing something in the documentation.

Message is only place where you can store custom data. Up to 1024bytes. Each 32bytes costs 0.05 XEM. Blockchain is not designed to store custom data.
If you need more than that maybe you should think again if you need do on blockchain. Maybe in blockchain you need only store some hash from data. Or maybe you should look at projects that handle storage and are integrated with blockchain. Like ProximaX.

2 Likes

Thanka for the reply. I’ll take a look at ProximaX, I was initially looking at something with IPFS however nothing is production ready and can guarantee data is kept. I think I can use it without data storage on chain ans oy small message.

Is the message saved in bytea or as a string? If it’s a string what encoding?

In database is saved as hexadecimal string. Nanowallet using UTF-8 so I think this is encoding you should use. Payload message in nanowallet is prepared using function:

var utf8ToHex = function utf8ToHex(str) {
var rawString = rstr2utf8(str);
var hex = “”;
for (var i = 0; i < rawString.length; i++) {
hex += strlpad(rawString.charCodeAt(i).toString(16), “0”, 2);
}
return hex;
}

Thanks for the info