add image of an asset

+1 vote
How I can add images of an assets while issuing an assets along with some extra informations of an asstes
asked Jan 3, 2017 by Sidhartha Sankar Mahapatra

1 Answer

+1 vote

For general extra information, use the custom fields which you can provide as a parameter to the issue command (see the API documentation). But you cannot embed a large piece of data in these custom fields. For that you have a few good options:

  • Create a stream for asset images, publish the image to the stream with a key that matches the asset name. This works well if all the parties who issue assets trust each other – they can be given the only write access to the stream.
  • Create a stream for asset images, publish images to the stream, and embed the txid of the stream item in one of the asset custom fields. This does not require trust between those who issue assets, because each issuer explicitly references the image that they added for that image.
  • If you want to avoid using streams completely, you can embed the image in an extra metadata output of the asset issuance transaction, which you would create using createrawsendfrom. It can then be retrieved from the same transaction using getrawtransaction. This is the method used by the MultiChain web demo here. The command is like this (italic words to be replaced):

createrawsendfrom from-address '{"to-address":{"issue":{"raw":raw-number-units-issued}}}' '[{"name":"asset-name","multiple":raw-to-display-multiple,"open":true-or-false,"details":{"custom-key-1":"custom-value-1,"custom-key-2":"custom-value-2"}},"raw-image-content-as-hex"]' send

  • You could also use createrawsendfrom to publish the image into a stream in the same transaction as the issuance command, replacing raw-image-content-as-hex above with {"for":"stream", "key":"", "data":"raw-image-content-as-hex"}. That would allow you to retrieve the image with getstreamitem using the issuance txid.
answered Jan 3, 2017 by MultiChain
...