A ⭐️ is welcome!
     [](https://github.com/dbpunk-labs/db3/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)  [](https://twitter.com/Db3Network) [](https://www.gitpoap.io/gh/dbpunk-labs/db3) [](https://discord.gg/sz3bmZx2uh) **English | [中文](./README_zh_cn.md)** ## DB3 Network DB3 Network is an open-source and decentralized firebase firestore alternative for building fully decentralized dApps quickly with minimal engineering effort.
## Why DB3 Network

Currently, there are two types of Data architecture for dApp(decentralized application): centralized vs. decentralized.
**Centralized**: use [Firebase](https://firebase.google.com)
or [MongoDB](https://github.com/mongodb/mongo)
to store the data), both of which are developer-friendly. However, dApps would be regarded as less secure based on a central database.
**Decentralized**: use Ethereum
or other blockchains to store the data and use [the Graph](https://thegraph.com/en/) to index data from it. The separation of the storage and the indexer would cost a lot of engineering efforts in future development.
With Db3 network, you can get both advantages of the above two choices.
# Features
**Schemaless**
You can store data on DB3 Network without any change.
**High Performance**
Currently, decentralization means terrible performance, but DB3 is trying to improve it significantly:
* [Merkdb](https://github.com/dbpunk-labs/db3/issues/100) is the storage engine of the DB3 Network, and it has high Performance and fast-proof generation.
* Geo distribution: the nodes in every storage shard are geo-distributed, and the clients can execute queries against the nearest storage node.
* [Query session](./docs/query.md), the first decentralized query protocol to resolve Performance and incentive perfectly.
**Data Ownership**
We proposed [the document level ownership](https://github.com/dbpunk-labs/db3/issues/271), and every document has its owner, while only the owner holds the private key can update/delete the record. DB3 network generates the proofs and provides signatures to prove the membership (db3 has the specific document) and ownership.
**Programmable**
Dapp developers can develop data processing contracts and deploy them to the DB3 Network, just like the data backend in web2.
**Ethereum Guarded Security**
DB3 Network is a layer2 network on Ethereum and Ethereum guards all the assets.
# Getting Started
### Build
git clone https://github.com/dbpunk-labs/db3.git
cd db3 && bash install_env.sh && cargo build
# start localnet
cd tools && sh start_localnet.sh
./target/debug/db3 console
db3>-$ new-db
database address | transaction id
--------------------------------------------+----------------------------------------------
0xa9f5c8170aad7a0f924d89c6edacae6db24ef57d | 0ALy/hH7CQe9lv294K6dOxGP14xWHsbRs+/pXBZa8oU=
db3>-$ show-db --addr 0x7e16cb6524e2fc21ae9bf2d7ee18b05767b9dc33
database address | sender address | releated transactions | collections
--------------------------------------------+--------------------------------------------+----------------------------------------------+-------------
0x7e16cb6524e2fc21ae9bf2d7ee18b05767b9dc33 | 0x96bdb8e20fbd831fcb37dde9f81930a82ab5436b | EMYw64xlI2q4v1MShoKw3T60asNbWJ9//ca75M3JO3Q= |
db3>$ new-collection --addr 0xcfb524677673af15edebbec018b16d42d87b1251 --name books --index '{"name":"idx1","fields":[{"field_path":"test1","value_mode":{"Order":1}}]}'
send add collection done with tx
3V7r7VRg+9zUXeGNmqRR0YdVXWtBSl4sk+Z50h9BrOc=
db3>-$ show-collection --addr 0xcfb524677673af15edebbec018b16d42d87b1251
name | index
-------+----------------------------------------------------------------------------
books | {"name":"idx1","fields":[{"field_path":"test1","value_mode":{"Order":1}}]}
db3>-$ new-doc --addr 0x997f631fcafeed5ee319c83683ae16e64783602b --collection-name books --documents '{"name": "John Doe","age": 43,"phones": ["+44 1234567","+44 2345678"]}'
send add document done with tx
+O9cK2cHLexZQvIITk4OTm8SxBhq7Yz7g+xZYiionWo=
/*
|----------------------------|
| use db3js open a database |
|----------------------------|
*/
// build sign function
const sign = await getSign()
// build database factory
const dbFactory = new DB3Factory({
node: 'http://127.0.0.1:26659',
sign,
nonce
})
// open database with an address
const db = dbFactory.open("0x5ca8d43c15fb366d80e221d11a34894eb0975da6")
![]() Protocol Labs |
![]() Filecoin |