Join to Write Data Into Your First Decentralized Databaseby@xutweety
723 reads
723 reads

Join to Write Data Into Your First Decentralized Database

by Man XuDecember 1st, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The DB3 Network is a start-up project to build a decentralized, permissionless platform for programmable data processing. Compared with the current popular file-based “decentralized storage”(e.g. Arweave, Filecoin), it plays the role of a database in Web3, which improves the convenience of data use and facilitates effective data retrieval and access for users.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Join to Write Data Into Your First Decentralized Database
Man Xu HackerNoon profile picture

The DB3 Network is a start-up project to build a decentralized, permissionless platform for programmable data processing. Compared with the current popular file-based “decentralized storage”(e.g. Arweave, Filecoin), it plays the role of a database in Web3, which improves the convenience of data use and facilitates effective data retrieval and access for users.

You can experience data reading and writing from the test network, become validators, participate in the PoS consensus, and earn income.

Network Roles

In our network, temporarily, there are four roles:


Users claim data ownership in our network. You could write into, modify, delete, query, share with others, or assign the access right to a third party, all the above data operations are supported in our network. At the same time, these operations need to be paid for because they consume the network’s resources.


dApp mainly assumes the intermediary responsibility of users to query or write personal data, which is an essential foundation for the prosperity of the entire network. Users interact with the internal storage logic of DB3 through the agreed smart contract logic in dApp to complete the data operations as above-mentioned.


Users can pay through the wallet, and the wallet will record the user’s credit balance and complete some necessary signature interactions through the wallet.


Validator undertakes two important responsibilities in our network. First, stake and broadcast to ensure node consensus; second, because the nodes owned by Validator can provide resources for data storage and computing, the Validator also undertakes similar node services. Therefore, an additional service fee will be received, similar to the Saas service in web2.

DB3 Network

The network will include three parts: storage shard chain, settlement chain, and computing layer. The three work together.

DB3 components, image by author

A KV storage engine in the storage shard chain records the interaction process between each user account and the bill generated by the writing or query data process. Each node in the computing layer performs calculations through DVM. The generated calculation results are verified through DVM in the Mempool; the nodes in the settlement chain are responsible for the settlement and summary of the bills output in the storage chain.

The interactive process is in the following:

image by author

TestNet Application Scenarios

The overall network mainly implements the above “storage shard chain.” Based on this, we tentatively summarize the following two cases:

Decentralized social dApp

Based on DB3 network, the social dApp platform could be built, image by author

It is recommended that dApp developers use our TestNet to store part of the social information in advance, such as user profiles, follower information, and tweet information. At the same time, we are also making progress in optimizing persistent storage based on the existing Merkle tree solution. When the optimization is completed, the developer can store all the information of the tweet content in the DB3 network; you can find the brief introduction in our sub-project issue. In our Phase 2 development stage, when we finish the DVM computing layer, users can write smart contracts to process and implement the logic in applications such as payment tokens and mint NFT.

The current SDK use case:

Submit a mutation: write a follower name to my personal namespace.

// import the db3js
import { DB3, generateMnemonic, generateKey } from "db3";
// config the db3 node
const db3_instance = new DB3("");
// subimit your follower data and store in your namespace
const response = await db3_instance.submitMutation({ns: 'my_namespace', gasLimit: 0.3, data: [{follower: lily}]}, private_key);

MySQL Real-time Hot Back-up

To ensure the effect of data read&write performance, the current dApps still maintain a set of centralized databases, such as MySQL, as part of their services. At the same time, to reflect its decentralized permanent storage characteristics, MySQL will synchronize some data to Arweave. But this synchronization is often asynchronous and non-real-time, and it is not easy to recover from Arweave, let alone operations such as indexing and querying. This approach is often only assumed to prevent loss.

image by author

Using the DB3 network, you can conveniently carry out a real-time hot backup of the database and restore your data from the network at any time, ensuring the stability of your application services. This way, your infrastructure’s purity of “decentralization” is further improved.

What’s included in DB3 TestNet

Users can write and query data in the chain and generate account bills. Our current tool packs include:

  • Four nodes service: our above storage service has been running on four test nodes distributed in multiple regions worldwide.

  • DB3 CLI tool: you can write, modify and query data; meanwhile, the bill is generated. DB3 CDC(Change Data Capture)

  • CLI tool: you can hot backup the centralized database MySQL database to the DB3 network in real-time, and you can view the backup data in our network and recover it when you need.

    // When the backup is successful, a mutation is successfully completed, and a mutation ID and basic information used by your account will be returned
    2022-11-21T04:47:29.038953Z  INFO db3cdc: no gtid state in db3
    WARNING, db3 will generate private key and save it to /home/jackwang/.db3/user.key
    restore the key with addr 0x97b478ac2bef8762c2ecc08417f35838c4bf73fc
    2022-11-21T04:47:29.040835Z  INFO db3cdc: binlog options BinlogOptions { filename: "", position: 4, gtid_set: None, gtid_list: None, starting_strategy: FromStart }
    2022-11-21T04:47:29.349037Z  INFO db3cdc: mutation id "tWYRruF8dSwvOySMypYCD0pJTVZgquKZu116UddTAps="
    2022-11-21T04:47:29.429778Z  INFO db3cdc: Your account 0x97b478ac2bef8762c2ecc08417f35838c4bf73fc status: total bills 0.000000 db3, total storage used 0.00 , total mutation 0, credits 10 db3

  • Blockchain Browser: you can clearly see the block generation process, data query and writing, and corresponding data.

  • DB3 JS SDK: you can implement web3 native full-stack application development based on the Typescript and write some backend logic.

What’s NOT included in DB3 TestNet

  • The network does not contain smart contracts or DVM-related features, and it is temporarily unable to settle bills. This is part of our second phase of development.
  • For the time being, we have not encrypted the data, but in the future, we will design a more refined access control method and adopt different protection methods for privacy in different scenarios.
  • The test network uses different configuration parameters from our main network; that is to say, we temporarily use fewer shards and fewer validators. We are also not optimized for a large number of validator joins, such as some fork-choice rules and, among other features, that will make the code robust enough for hundreds of thousands of validators to join.

Joining DB3 TestNet

Become a Validator

For the time being, you can support our network by running a node without staking. No detailed documentation yet, but you can contact us; running a node helps keep our network alive and increases the decentralization of our testnet.

I want to build my first decentralized database

Following Getting started to write some data

I want to contribute to the code

Our Github

Browse some design docs; Start coding from goodfirstissue; Discuss with us according the WIPissue.

Also published here.