**NOTE: service must be set as active (running), if not please verify the preview steps**
# [OrbitDB](https://github.com/orbitdb/orbit-db)
OrbitDB is a **serverless, distributed, peer-to-peer database**. OrbitDB uses [IPFS](https://ipfs.io) as its data storage and [IPFS Pubsub](https://github.com/ipfs/go-ipfs/blob/master/core/commands/pubsub.go#L23) to automatically sync databases with peers. It's an eventually consistent database that uses [CRDTs](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) for conflict-free database merges making OrbitDB an excellent choice for decentralized apps (dApps), blockchain applications and offline-first web applications.
**Start IPFS Daemon** (Note: pubsub-experiment is necesary to work with OrbitDB)
```sh
$ ipfs daemon --enable-pubsub-experiment
```
**Start the DecaCC Interface**
```sh
$ node interfaz.js
```
**Note: With this you can use OrbitDB but only in your local node**
## Usage with replication
You need to do all the past steps.
Run index.js with uncomment line 24, 25, the first log is your orbitdb address (See the Wiki for more information), the second is your orbitDB address database copy this address and pass in index.js in line 6, and in interfaz.js in the same line.
**If you want to debug orbitdb in bash**
```sh
$ export LOG="orbit*" node
```
**Start the DecaCC replicated**
```sh
$ node index.js
```
Later in the nodes that will work like peers only, install the requeriments and run index.js with the new address.
**Start the DecaCC Interface**
```sh
$ node interfaz.js
```
In the node that can write run interfaz.js and choose an option.
```sh
$ Show Carbon Credit records
$ Insert Carbon credit
$ Delete Carbon credit
$ Exit
```
**Note: If the nodes will replicated you need connect before with IPFS Daemon (See Wiki).**
*Note 2: Remember dont lost your orbitdb folder because your identity.id change and cant write in a database another time*
## Connect Nodes
In order to connect nodes, we create a bash script which resolves the domain name of each node and ipfs swarms them,
this script should be configured in a crontab to run every 5 minutes. The crontab should be configured as the user
that holds this repository and that runs the orbitdb.
*Open the crontab as the user that holds the script*
```sh
$ crontab -e
```
*Append the following line at the end of the editor and write it*
**You can help us by pinning DECA's project receipts into IPFS which will give deeper trust to DECA.**
We have a script in order to pin (replicate into your node) the projects receipts that DECA got, so that
any one can have a proof that we bought this receipts as public information. Also you can store a copy of this receipts which will be added by IPFS hash into this script.
As you can see in the above example we pin the receipt by running " ./receipts.sh ", also we Download this receipt with should be allocated in the directory projects Receipts.