Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Blockchain by (4.1k points)

I'm in the process of creating an Ethereum DApp. The DApp consists of users who have associated data like email, name, and a profile picture. I would like to store the contents of the user within IPFS as a JSON object and reference this on the chain using the IPFS hash. How could I go about associating this data with a particular user? In the sense, that subsequent interactions with the DApp connect the user with the data stored in IPFS. Is this done using the user's account hash with a password of some sort?

For example, user A is interested in using the DApp and so, provides his or her email, name, and profile picture. Then any subsequent interaction with the DApp, like a comment or post would link this user to the respective user data in IPFS.

Any suggestions or adjustments to this way of modeling users would be greatly appreciated. Thanks!

(P.S. I come from the traditional web/mobile app world so I'm just getting accustomed to modeling things using smart contracts. So I apologize in advance if this is a simple or ill-structured question.)

1 Answer

0 votes
by (14.4k points)
edited by

The fact that users can build ZERO click login using Ethereum, makes this blockchain platform a masterpiece. When the user’s web3.eth.accounts[0] is established, there is no hiding the fact that a user controls the private key of that particular account address. Thus, the validity of a user can be guaranteed. 

Now coming onto your question. For using IPFS as a database, you need to keep in mind the following things. 

For User Signup: 

  • Sign up user data is collected in a JSON object.

  • Then create a file and write that JSON object to that file. 

  • Pass that file on to IPFS and get the file has (the IPFS file location)

  • Store that hash in an Ethereum based contract that associates the user’s account with the IPFS file hash. 

For User Validation: 

  • When users visit the website, web3js gets the active Ethereum account

  • Read the user contract and identify the associated IPFS hash. 

  • Get the file from IPFS and read the JSON object

  • Extract data from a JSON object and display the same to the user. 

Give yourself time to explore this field properly. Enroll in IBM Blockchain Certificate now.

Browse Categories

...