Decentralized social media dapp


Detwitter is a sample dapp that shows how a decentralized social media app like Twitter can be built with DB3. The code is here.
Being built on top of the DB3 database network, Detwitter allows its users to maintain complete control and autonomy over their data, allowing users to speak confidently, knowing that only they control the keys to their own communication. The features of Detwitter include:
  • Create users' wallets
  • Create DB3 user accounts
  • Glance the global users
  • Publish tweets
  • Build social relationships that follow and be followed
  • Browse the tweets of your following users

Access control

Both the users, the dapp and smart contract have a unique Detwitter address.
According to the ownership of the data, there are two ways to access users' data.
  • The user's own account data can be accessed through SQL running without the permissions. The method is run_sql_by_owner by the data owner;
  • Besides the user himself, the other way is that users and dapp can authorize smart contracts running in DVM to complete cross-account data access.

Data tables

The user owns at least three data tables:
  • my_twitter_following (storing the list of your following people)
  • my_twitter_followme (keeping the list of the names that follow you)
  • my_twitter_tweets (keeping the list of the content of your tweets)
These three tables are created after the user grants the smart contract address of @5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy
authorization to create the above three tables for a user under their namespace of my_detwitter.
The dapp of Detwitter owns the data table:
  • global_detwitter_userlist
Data access relationship
Creat DB3 user accounts
User authorizes smart contract to insert a record into the dapp’ table global_detwitter_userlist
Glance the global users
user authorizes smart contract to query the dapp’s global_detwitter_userlist
Publish tweets
User insert a record into the user’ table my_twitter_content
follow someone
User A authorizes smart contract to check the permission of the user B and then insert a record in user A’s my_twitter_following , a record in user B’s my_twitter_followme
get your following persons’ tweets
User A authorizes smart contract to query itself’s my_twitter_following list; user B authorizes smart contract to query itself’s my_twitter_tweets
For all the above authorization processes, the user's signature must be obtained. The authorization content will inform the user of the above authorization relationship and the corresponding data tables involved.
Next, we will show you how to build the simplest dapp with DB3 and .js.
The instruction is on the way.