1

I am trying to store image data as hex in a smart contract. How can i do so. I am not able to find a way to convert image to hex in javascript. How can i do that as well?

  • Is this for a proof-of-concept on a private network, or a real-life, main net contract? If it's the latter, it's going to be (very) expensive. Your best bet would be to store it offchain... See: Image attached to Ethereum contract (off-chain) – Richard Horrocks Jan 8 '18 at 14:19
  • I will actually store the hash of the data, not the entire data, so i just want to convert image to data array. – Kashish Khullar Jan 8 '18 at 14:22
  • Aha, okay, in that case the previous question I've linked to should help. It looks like one of the answers also contains some pointers to examples of how to do it. – Richard Horrocks Jan 8 '18 at 14:26
1

Why not just get byte data of the image offline with a small script and then pass that in as bytes32, hash with keccak, and store in smart contract?

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.