Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update readme #143

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 50 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# 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`).
The [Document Store](https://github.com/Open-Attestation/document-store) repository contains the following:

* The smart contract code for document store in the `/contracts` folder
* The node package for using this library in the `/src` folder

## Installation

To install OpenAttestation document store on your machine, run the command below:

```sh
npm i @govtechsg/document-store
```
Expand All @@ -12,25 +17,35 @@ 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).
Provide one of the following depending on your needs:

* To use the package, provide your own Web3 [provider](https://docs.ethers.io/v5/api/providers/api-providers/).

### Deploy new document store
* To write to the blockchain, provide the [signer](https://docs.ethers.io/v5/api/signer/#Wallet) instead.

### Deploying a new document store

The following shows a code example to deploy a 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
### Connecting to an existing document store

The following shows a code example to connect to an existing document store:

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

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

### Interact with document store
### Interacting with a document store

The following shows a code example to interact with a document store:

```ts
const issueMerkleRoot = async () => {
Expand All @@ -47,30 +62,30 @@ const issueMerkleRoot = async () => {

### 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:
The following is a list of available functions to be used with document store:

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

## Provider & signer

The following code example shows different ways to get the provider or signer:

```ts
import { Wallet, providers, getDefaultProvider } from "ethers";
Expand All @@ -90,21 +105,23 @@ signerFromMnemonic.connect(provider);

## Setup

You can install dependencies, check source code, test your project, and use the Truffle development framework with the commands below:

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

## Contract Benchmark
## Contract benchmark

A benchmark is provided to show the different transaction cost of the different variants of the document store.
To show the different transaction costs of the different variants of the document store, run the contract benchmark with the command below:

```sh
npm run benchmark
```

## Notes
## Additional information

If you are using vscode, you may need to link the openzeppelin libraries. Refer to [here](https://github.com/juanfranblanco/vscode-solidity#openzeppelin).
If you are using Visual Studio Code, you may need to link the OpenZeppelin libraries. Refer to [here](https://github.com/juanfranblanco/vscode-solidity#openzeppelin) for more information.
Loading