Handling user profiles in Ethereum DApps

前端 未结 1 1935
栀梦
栀梦 2021-01-31 21:17

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

相关标签:
1条回答
  • 2021-01-31 21:54

    One of the beauties of using a platform like Ethereum is that you can build a ZERO click login. If we establish that the user's web3.eth.accounts[0] is proof that the user controls the private key of that account's address, then you will always know that the user is valid.

    If you want to use IPFS like a database, my suggested approach would be this:

    Note that with most decentralised systems a lot of the action happens on the client side.

    User Signup

    • Users have Ethereum accounts.
    • On sign up user data is collected into a JSON object
    • A file is created, write JSON object to file.
    • Pass file to IPFS
    • Get file hash (which is basically its IPFS location)
    • Store the IPFS hash in an Ethereum contract that associates the user's Ethereum account with the IPFS file hash.

    User Validation

    • User visits the website
    • web3js gets the active Ethereum account
    • Read from the user contract to find the associated IPFS hash
    • Get file from IPFS
    • Read the JSON object
    • Extract the data from the JSON
    • Display data to user
    0 讨论(0)
提交回复
热议问题