1

Scenario - need to store on blockchain specific data related to users.

  • potentially very large number of users
  • data should not be changed in the future, and that's the whole point to make it immutable
  • smart contract should have ability to check it for any user at any time
  • data size to store per user is small
  • the data should not be easy to find or interpret on blockchain for general public

From my understanding there are 2 ways:


Store in transaction's data

  • cheaper to store
  • if user personal information is stored in a offchain database, the data on blockchain can reference it by primary key. Database can store all transactions for specific user for fast search

Questions

  • Does having part of data stored offchain beat the purpose of using blockchain in terms of if database is somehow lost/corrupt then data stored in a contract becomes useless?
  • Is there a point of using Swarm/IPFS instead of regular database? what benefits it would have?
  • Can a smart contract easily access a transaction's data? is it free or not?

Store in smart contract's data

  • expensive to store
  • info is easy to find within contract's data structures

Questions

Since contract's data can be modified, it looses the immutability benefit? can the changes to contract's data be tracked on blockchain?

1 Answer 1

2

Out of all of your scenarios, "the data should not be easy to find or interpret on blockchain for general public" will probably be the most complex part.

Let's go over each option.


Store in transaction's data

  • (True) cheaper to store
  • (True) if user personal information is stored in a offchain database, the data on blockchain can reference it by primary key. Database can store all transactions for specific user for fast search

Questions

  • Does having part of data stored offchain beat the purpose of using blockchain in terms of if database is somehow lost/corrupt then data stored in a contract becomes useless?

(True) Just like anything that indexed with a key, if the key leads to lost or corrupt data, then the key is useless.

  • Is there a point of using Swarm/IPFS instead of regular database? what benefits it would have?

Swarm/IPFS would allow you to distribute the database in a similar fashion like the blockchain so there's not a single point of failure. Encryption/decryption would have to be handled end-to-end if security is an issue.

  • Can a smart contract easily access a transaction's data? is it free or not?

Easily, no. You'd essentially have to use an oracle (which also could handle decryption if you go that route) to transfer the data to the contract itself.


Store in smart contract's data

  • (True) expensive to store
  • (True) info is easy to find within contract's data structures

Questions

  • Since contract's data can be modified, it loses the immutability benefit?

Immutability and modification are 2 different concepts in this scenario. Once written on the blockchain, the data is immutable...but a value of a storage pointer can be updated with new immutable data. Data is never really changed, but the pointer is updated to a new storage value. Update is probably a better word in this case than modification.

  • Can the changes to contract's data be tracked on blockchain?

Based on what I said above, yes, all updates can be tracked.

2
  • Thanks for the answer. Could you elaborate a bit on "Encryption/decryption would have to be handled end-to-end if security is an issue", this part is not clear to me.
    – Serge
    May 1, 2018 at 1:49
  • @Serge Well, for the blockchain, and IFPS/Swarm, data continuity has to be verifiable but you can get away with using something like GPG encryption on IFPS. This blog, "Learn to securely share files on the blockchain with IPFS!" is a good example article on what that process looks like.
    – ReyHaynes
    May 1, 2018 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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