[Ethereum] How to upload and download files to the blockchain

blockchaincontract-designstorage

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

Best Answer

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?

Related Topic