4

I need little direction on what must be maintained in BC and what must be maintained outside BC. For example I have to maintain book info like name, title, author, book cover as image, price. Can I maintain all the attributes in blockchain? Should I keep the images outside blockchain?

Also how can we keep the information of an entity in sync between the 2 sources?

Thanks in advance for your time and help!

1

1 Answer 1

6

In general, the blockchain is not meant to save a lot of data. Data storage in ethereum is quite expensive. One approach would be to save a hash of the data in the blockchain and store the actual data in a database or on IPFS or Swarm. It is definitely a good idea to keep images outside the blockchain. If you store images in IPFS or Swarm, you will get a hash of the data and you would store the hash in the blockchain. Since the hash is calculated based on the actual data of the image, you can also make sure that the image was not changed after you stored it.

The right approach to sync between the two sources is to use events. You can define events in your smart contracts. When you call a function of the smart contract, the event will be fired. You can catch the events in your application. If the transaction was successful, you can write the data to your database or to IPFS/Swarm.

This is more like a general explanation. If you need detailed guidance on how to implement this kind of approach, you can write a comment and I will post some links where you can find the detailed information.

I hope that helps.

2
  • Thank you so much for the info, it would be of great help if you could provide other useful links.
    – Arun Kumar
    Commented Nov 22, 2017 at 12:11
  • Would be interesting to read those links you suggested
    – HeyJude
    Commented Mar 28, 2019 at 20:36

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