# @truffle/db

> Smart contract data aggregation

Latest version **2.0.36** (published 2023-09-13) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @truffle/db
pnpm add @truffle/db
yarn add @truffle/db
bun add @truffle/db
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.36 |
| Published | 2023-09-13 |
| First published | 2020-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | ^16.20 \|\| ^18.16 \|\| >=20 |
| Dependencies | 19 |
| Unpacked size | 12.5 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13914 |
| Author | g. nicholas d'andrea |
| Maintainers | rizedr, joshuafernandes, cliffoo, kevinbluer, gnidan, haltman, eggplantzzz, fainashalts, cds-amal |
| Keywords | database, ethereum, smart-contracts, truffle |

## Links

- npm: https://www.npmjs.com/package/@truffle/db
- Repository: https://github.com/trufflesuite/truffle
- Homepage: https://github.com/trufflesuite/truffle/tree/master/packages/db#readme
- Issues: https://github.com/trufflesuite/truffle/issues
- npm.io page: https://npm.io/package/@truffle/db

## Dependencies (19)

- [debug](https://npm.io/package/debug.md) ^4.3.1
- [graphql](https://npm.io/package/graphql.md) ^15.3.0
- [pouchdb](https://npm.io/package/pouchdb.md) 7.3.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.1.0
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [web3-utils](https://npm.io/package/web3-utils.md) 1.10.0
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.12.6
- [pascal-case](https://npm.io/package/pascal-case.md) ^2.0.1
- [pouchdb-find](https://npm.io/package/pouchdb-find.md) ^7.0.0
- [apollo-server](https://npm.io/package/apollo-server.md) ^3.11.0
- [pouchdb-debug](https://npm.io/package/pouchdb-debug.md) ^7.1.1
- [@truffle/config](https://npm.io/package/@truffle/config.md) ^1.3.61
- [@truffle/abi-utils](https://npm.io/package/@truffle/abi-utils.md) ^1.0.3
- [abstract-leveldown](https://npm.io/package/abstract-leveldown.md) ^7.2.0
- [@truffle/code-utils](https://npm.io/package/@truffle/code-utils.md) ^3.0.4
- [@graphql-tools/schema](https://npm.io/package/@graphql-tools/schema.md) ^8.3.1
- [json-stable-stringify](https://npm.io/package/json-stable-stringify.md) ^1.0.1
- [pouchdb-adapter-memory](https://npm.io/package/pouchdb-adapter-memory.md) ^7.1.1
- [@graphql-tools/delegate](https://npm.io/package/@graphql-tools/delegate.md) ^8.4.3

## Recent versions

- 2.0.36 (latest) — 2023-09-13
- 2.0.22-visual-debugger.0 (visual-debugger) — 2023-05-12
- 1.0.21-hardhat-error.0 (hardhat-error) — 2022-08-25
- 1.0.15-typescript-migrations.0 (typescript-migrations) — 2022-07-21
- 1.0.11-alpha.2 (signTypedData_v4) — 2022-06-24
- 0.5.50-dashboard.1 (dashboard) — 2022-02-01
- 0.5.33-decoder-beta.0 (decoder-beta) — 2021-09-29
- 0.5.30-alpha.1 (eip1559-beta) — 2021-09-13
- 0.5.15-cheerios.1 (cheerios) — 2021-06-10
- 0.5.15-decoder-no-web3.0 (decoder-no-web3) — 2021-06-09
- 0.5.4-preserves.0 (preserves) — 2021-03-24
- 0.1.1-abi-utils.0 (abi-utils) — 2020-10-12
- 2.0.35 — 2023-09-07
- 2.0.34 — 2023-08-29
- 2.0.33 — 2023-08-04
- … 145 more at https://npm.io/package/@truffle/db/versions

## README

# `@truffle/db`

Truffle DB is a complete, flexible system for the querying and mutation
of Truffle’s smart contract records. Following the data model available [here](https://trufflesuite.github.io/artifact-updates/data-model.html),
Truffle DB persists smart contract information that is typically found in
a project's artifacts, and allows for querying this data using `GraphQL`.

</br>

Truffle artifacts are currently stored as JSON files in a project’s `build/contracts/`
directory. These documents are currently the canonical source of information about
a project’s smart contracts. While useful, artifacts can be limited for certain advanced
use cases.

</br>

For example, the artifacts format expects contracts with unique names.
This means that currently a developer is unable to keep two contracts in their project
that have the same name. Truffle DB solves this problem with a name record-keeping
system that can keep track of multiple contracts in this situation.

## Built With

Truffle DB is built with:
- TypeScript
- GraphQL
- Apollo
- PouchDB

## Configuration to enable Truffle DB

Add the following to your `truffle-config.js` file in order to enable Truffle DB

```
db: {
  enabled: true
}
```
Note: Enabling Truffle DB does not affect artifacts, but will produce a new `.db`
directory when you compile or migrate your project.


It will soon be possible to load and access Truffle DB data via `truffle compile` and `truffle migrate`.
Stay tuned!

## Usage

```
const { connect } = require("@truffle/db")

```

## License

MIT

---
_Source: https://npm.io/package/@truffle/db · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
