Skip to content

Commit

Permalink
docs: update readme (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
rollerchloe authored Feb 20, 2024
1 parent 2271435 commit c96c019
Showing 1 changed file with 50 additions and 33 deletions.
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.

0 comments on commit c96c019

Please sign in to comment.