As I understand it, smart contracts are currently immortal by default. Does this mean that I could create a contract that happened to contain an encoded form of baby photos and have it stored forever? If not, what prevents it?

up vote 36 down vote accepted

Nothing prevents it. 5 months ago, I demonstrated storing audio (a very highly compressed mp3 file) in the blockchain. And it's still there and being replicated by every full node today! Only 3.5kB and I had to pay quite a bit of ether, but still cool!

Check out Freakiest thing ever - the blockchain now has a voice! thread at Reddit.

To make this answer last the test of time (if something happens to the above link), here is the relevant command to run in your terminal:

geth --exec "eth.getTransaction('0xbb8ee9866ee67277986b6f40775469c7a674810ce99dce3caff0d1117c8dcdac').input" console | xxd -p -r | mpg321 -

A smarter way uses the storage only as a hash as other answers have said, use StorJ, IPFS, etc., because then you can store more off the blockchain and link to it.

  • 1
    That is awesome! It took me awhile to actually get the data and play it, geth didn't seem to think the address existed, xxd wasn't installed, mpg321 wasn't in the official repos, so I had to find it on a blockchain explorer site, install xxd, and then use ffplay, and it was all worth it XD. – Shelvacu Jan 23 '16 at 7:44
  • shelvacu: Great to hear! Glad you had a bit of fun with it, I know I did. :) I had the first functional contract on the Ethereum blockchain. – linagee Jan 23 '16 at 7:48
  • 1
    Nothing prevents it....except the extraordinarily high costs compared to any other solution. Please mention in your answer that people shouldn't actually do this--as mentioned IPFS is a much better way to have some data stored forever without bloating the Ethereum blockchain. And in fact, if people wait for projects such as Swarm to be completed, they will be able to pay less than the cost of the blockchain storage method into a contract that will ensure the same thing. – Jeff Coleman Jan 23 '16 at 20:01
  • 1
    How much did you pay? – Matías Insaurralde Jan 24 '16 at 5:33
  • 1
    @MatíasInsaurralde I've heard $0.25 on Reddit. – sidney May 23 '16 at 8:53

The primary things "stopping you" would be:

  1. Block gas limits which are currently "voted on" by miners
  2. Amount of gas you would need to pay to store your data

Things like baby photos are going to be, at minimum, 600kB uncompressed. I am not incredibly familiar with image compression, so we will just work with the 600kB figure for the sake of example.

A transaction sending 46kB of compressed text consumed 1,720,210 gas and cost 0.0860105 Ether ($0.074 USD) at the end of October 2015. The price since then for Ether will continue to rise/fall, but ignoring that for a moment, let's do the math:

Storing the 600 kB image would cost 13 times more gas to store, so 22,362,821 gas would be consumed for a cost of $0.96 (if priced from Oct. 2015). The current block gas limit is 3,141,592 gas which is much less than the required amount to process the image in 1 transaction.

So it is possible to store images on the Ethereum blockchain, but a much cheaper solution would be to store a reference to that image (like a URL) to permanently store where the image is kept, granted that is not as useful as permanent storage. In the future, IPFS will likely be able to store data indefinately once they nail down an incentive system for people to store the data. Then it is just a matter of storing the IPFS hash that points to the image.

Its technically possible, there are some apps do the same as well.

  3. Scaling Blockchain-based Data Stores

The data types that can be stored are limited, so storing baby photos would take a lot of code to map it to the available types. Plus of course you need to pay Ether to the contract to use its storage, so it's not free.

Other option to store data is:

  • Welcome to Ethereum! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Afri Jun 1 '17 at 10:03

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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