# @govtechsg/document-store

> The [Document Store](https://github.com/Open-Attestation/document-store) repository contains both the smart contract code for document store (in `/contracts`) as well as the node package for using this library (in `/src`).

Latest version **3.0.0** (published 2023-09-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @govtechsg/document-store
pnpm add @govtechsg/document-store
yarn add @govtechsg/document-store
bun add @govtechsg/document-store
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-09-25 |
| First published | 2020-03-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 589.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | GovTech |
| Maintainers | govtechsg_a11y, younglim, gtrgchua, isomer.govtech, gyunikuchan, gds_ace_dlt, gdsbot, gylsky, ryanoolala, dyihoon90 |

## Links

- npm: https://www.npmjs.com/package/@govtechsg/document-store
- Repository: https://github.com/Open-Attestation/document-store-contract
- Homepage: https://github.com/Open-Attestation/document-store-contract#readme
- Issues: https://github.com/Open-Attestation/document-store-contract/issues
- npm.io page: https://npm.io/package/@govtechsg/document-store

## Recent versions

- 3.0.0 (latest) — 2023-09-25
- 2.6.1 — 2023-01-04
- 2.6.0 — 2023-01-04
- 2.5.0 — 2022-12-30
- 2.4.0 — 2022-11-09
- 2.3.2 — 2022-10-25
- 2.3.1 — 2022-08-08
- 2.3.0 — 2022-04-04
- 2.2.3 — 2021-09-27
- 2.2.2 — 2021-08-27
- 2.2.1 — 2021-04-30
- 2.2.0 — 2020-12-07
- 2.1.0 — 2020-11-27
- 2.0.0 — 2020-08-07
- 1.1.6 — 2020-04-17
- … 12 more at https://npm.io/package/@govtechsg/document-store/versions

## README

# Document Store

The [Document Store](https://github.com/Open-Attestation/document-store) repository contains both the smart contract code for document store (in `/contracts`) as well as the node package for using this library (in `/src`).

## Installation

```sh
npm i @govtechsg/document-store
```

---

## Usage

To use the package, you will need to provide your own Web3 [provider](https://docs.ethers.io/v5/api/providers/api-providers/) or [signer](https://docs.ethers.io/v5/api/signer/#Wallet) (if you are writing to the blockchain).

### Deploy new document store

```ts
import { deployAndWait } from "@govtechsg/document-store";

const documentStore = await deployAndWait("My Document Store", signer).then(console.log);
```

### Connect to existing document store

```ts
import { connect } from "@govtechsg/document-store";

const documentStore = await connect("0x4077534e82c97be03a07fb10f5c853d2bc7161fb", providerOrSigner);
```

### Interact with document store

```ts
const issueMerkleRoot = async () => {
  const documentStore = connect("0x4077534e82c97be03a07fb10f5c853d2bc7161fb", signer);

  const tx = await documentStore.issue("0x7fe0b58ed760804eb7118988637693c4351613be327b56527e55bcd0a8d170d7");
  const receipt = await tx.wait();
  console.log(receipt);

  const isIssued = await instance.isIssued("0x7fe0b58ed760804eb7118988637693c4351613be327b56527e55bcd0a8d170d7");
  console.log(isIssued);
};
```

### List of available functions

```text
documentIssued
documentRevoked
isOwner
name
owner
renounceOwnership
transferOwnership
version
initialize
issue
bulkIssue
getIssuedBlock
isIssued
isIssuedBefore
revoke
bulkRevoke
isRevoked
isRevokedBefore
```

## Provider & Signer

Different ways to get provider or signer:

```ts
import { Wallet, providers, getDefaultProvider } from "ethers";

// Providers
const mainnetProvider = getDefaultProvider();
const goerliProvider = getDefaultProvider("goerli");
const metamaskProvider = new providers.Web3Provider(web3.currentProvider); // Will change network automatically

// Signer
const signerFromPrivateKey = new Wallet("YOUR-PRIVATE-KEY-HERE", provider);
const signerFromEncryptedJson = Wallet.fromEncryptedJson(json, password);
signerFromEncryptedJson.connect(provider);
const signerFromMnemonic = Wallet.fromMnemonic("MNEMONIC-HERE");
signerFromMnemonic.connect(provider);
```

## Setup

```sh
npm install
npm lint
npm test
npm truffle <command>
```

## Contract Benchmark

A benchmark is provided to show the different transaction cost of the different variants of the document store.

```sh
npm run benchmark
```

## Notes

If you are using vscode, you may need to link the openzeppelin libraries. Refer to [here](https://github.com/juanfranblanco/vscode-solidity#openzeppelin).

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