Sendwithmetadata

+1 vote

Hello,

I'd like to store some meta-data on Multichain and have used the Sendwithmetadata command.:

  • sendwithmetadata [the_address] 123456789abcde and this works great.

However when I try same but extend the data I want to save such as:

  • sendwithmetadata [the_address] FirstName=Joe Lastname=Bloggs

it's rejected due to a parsing error.

Can you please advise how I should store not financial multi part meta-data?

Thanks,

 

asked Sep 8, 2016 by Jon

1 Answer

+3 votes

The sendwithmetadata API command has the syntax [address amount data-hex].  The working example provided by you ''[sendwithmetadata [the_address] 123456789abcde]" have the missing the amount field or the asset quantities json field. With presence of field it would like:

  • sendwithmetadata [the_address] 0 123456789abcde
  • sendwithmetadata [the_address] '{"some_asset_name":QTY}' 123456789abcde
Since the last argument required in Hex String, the API validation logic would fail to parse the "FirstName=Joe Lastname=Bloggs" as a hex string. Due to the space presence in between Joe and Lastname, parsing error is also encountered. 
 
Now to send the example data, it is required to convert the string to hex string data. For example In Java we have String getbytes, the bytes could be converted to Hex String. Now converting "FirstName=Joe Lastname=Bloggs" would result in hex string with value of "46697273744e616d653d4a6f65204c6173746e616d653d426c6f676773". Now we can use the command like:
  • sendwithmetadata [the_address] 0 46697273744e616d653d4a6f65204c6173746e616d653d426c6f676773
  • or
  • sendwithmetadata [the_address] '{"some_asset_name":QTY}' 46697273744e616d653d4a6f65204c6173746e616d653d426c6f676773
 
When reading the data back from blockchain, the hex string is needed to be reconverted to string in the application level (Hex String -> Byte Array --> String).
answered Sep 11, 2016 by 7sigma
...