How can I store user data on smart contract without exposing it to other nodes to read ? I read somewhere that you can store data pointers instead of data on contract and use it for offline data exchange. What does data pointer imply here ?
3 Answers
All the data you store in blockchain is public. This data pointer stuff makes little sense, so I suggest you refer the source of your article.
If you want to communicate secretly, you can encrypt the information so that only the address private key holder can decrypt it. You can, for example, encrypt credentials to a non-blockchain storage where data is kept.
The encryption and decryption of the message must happen on the client side. Blockchain acts only as a public transportation channel of the encrypted payload.
More information here: How to encrypt a message with the public-key of an Ethereum address
What you might be thinking of is a preimage. You can hash any kind of data, and provide only the hash (the preimage) to a smart contract. Later, you can provide the data and prove it was the same as the preimage by hashing it again.
The answer to this question might be helpful: How can we integrate IPFS with ethereum in DApps?
Essentially, the recommended pattern is to store large data on other services like IPFS, Swarm etc. When a file is added to IPFS, it returns a hash that can be used to retrieve the file contents with the URL: https://ipfs.io/ipfs/<hash>
. IPFS also provides a Javascript API.