I want to create smart contract which can upload and download file from blockchain. Is that possible? If so, how?

  • What exactly are you trying to achieve? Store data and retrieve it later? Download the whole blockchain in a contract? – axic Mar 10 '16 at 16:04
up vote 6 down vote accepted

So files, in the traditional sense that I assume you are talking about when you use the word "files", are not stored on the blockchain; data is. All data is stored in HEX format and the more data there is, the more gas it needs to run. For this reason it's not really efficient or cost-effective to store "files" on the blockchain.

Instead, it's recommended to store files via IPFS or another decentralized / p2p / etc. system. If you want to learn more about referencing data stored in one contract from another contract, please check out the following:

Interactions Between Contracts

and the followup question:

How to reference coin contract already onchain?

  • how can we do that using IPFS? @tayvano – BlockA May 27 '16 at 11:23

"All data is stored in HEX format and the more data there is, the more gas it needs to run. For this reason it's not really efficient or cost-effective to store "files" on the blockchain."

And what about a sort kind of business of publishing docs in blockchain to obtain tokens for any view/download? Any contract around?

  • Please don't add a question in your answer ;) – Nicolas Massart Mar 15 '17 at 10:53
  • I've questioned to a statement and not to the original question. I think the answer could be useful even to the original question considering that nothing is specified in it about the nature public or private of the files. @NicolasMassart – Symb932 Mar 15 '17 at 16:34
  • Welcome to Ethereum! If you have another question, please ask it by clicking the Ask Question button. – Afri Mar 15 '17 at 18:19
  • Oh sure!! In the hope not to receive so much smoke as answers! ;-) @5chdn – Symb932 Mar 16 '17 at 6:07

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.