1

I understand that its expensive impractical to store images directly in smart contracts, but I'm wondering if possible to store something like a thumbnail, say 50x50 with 8 bit color depth. Is that every expensive or impractical, if I put the data in some kind of array, for example?

I have read about IPFS, but I have understood that things can disappear from IPFS after a while unless a pinning service is used, and if I want this thumbnail is going to be in 20 or 30 years, I wonder if IPFS is a viable choice.

PS. A little research seems to suggest that the cost of storing 1Kb in a contract at a gas price of 10 Gwei is on the order of $11.00. I guess that array composed of 2500 UInt8 is roughly 2.5KB, so something like $27.00 (June 2021) in gas to write this contract at today's prices?

1 Answer 1

1

Looks like your math is in the ballpark:

  • 32 bytes in a single storage slot
  • 32 slots to hold 1Kb
  • 25,000 gas to write a single slot
  • 800,000 gas to write one KB.
  • $17 per KB at this moment's prices

You might want to consider using a carefully compressed JPG rather than writing raw pixels. The savings could be considerable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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