2

How write a whole documents in ethereum blockchain?

Suppose i have a text file halo.txt in my system. How to write it in ethereum blockchain and how to retrieve it?

I have gone through IPFS example but it is only returning hash value, I need to return full text.

1

Using IPFS is almost definitely the right approach, as writing data to the blockchain is usually prohibitively expensive. Having stored the data in IPFS and got the hash back, you can read the data using ipfs.cat(document_hash)

You may want to post another question with your specific IPFS problem if you can't figure it out.

If you want to put a document in storage, you can convert it to bytes then store the bytes on the blockchain, but you don't want to do this.

Putting documents in the event logs may be somewhat less impossible, but don't. Use IPFS.

| improve this answer | |
0

Yes, you could. It would just be expensive.

Storing one 256-bit word on the blockchain requires 20,000 gas. So each kb (32 256-bit words) of storage requires 640,000 gas. At the current price of gas, about $0.00001, each kb of storage would cost ~$6.40.

It's expensive to store data on the blockchain because that data has to be stored on every single node, many of which are running on personal computers. If storage were cheap, the blockchain would risk growing too big for many of those computers to manage.

| improve this answer | |
0

You can store the file on blockchain as well it will be costly also it will be clotting the blokcchain. I think the better approach could be uploading your text file on IPFS and storing the hash on the blockchain. Storing hash on blockchain is not costly and also you can retrieve hash anytime from blockchain and use ipfs cat(hash) to get your content.

| improve this answer | |

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.