Skip to content

Commit

Permalink
docs: update readme (#48)
Browse files Browse the repository at this point in the history
(cherry picked from commit 64e90c2)
  • Loading branch information
ryanseee authored and superical committed Nov 17, 2021
1 parent c97b857 commit 93bff7e
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Token Registry
[![CircleCI](https://circleci.com/gh/Open-Attestation/token-registry/tree/master.svg?style=svg)](https://circleci.com/gh/Open-Attestation/token-registry/tree/master)
[![codecov](https://codecov.io/gh/Open-Attestation/token-registry/branch/master/graph/badge.svg?token=Y4R9SWXATG)](https://codecov.io/gh/Open-Attestation/token-registry)

This repository contains both the smart contract code for token registry (in `/contracts`) as well as the node package for using this library (in `/src`).
# Token Registry

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

## Installing Package
## Installation

```sh
npm i @govtechsg/token-registry
```

## Package Usage
---

## Usage

To use the package, you will need to provide your own Web3 [provider](https://docs.ethers.io/ethers.js/html/api-providers.html) or [signer](https://docs.ethers.io/ethers.js/html/api-wallet.html) (if you are writing to the blockchain).
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).

### TradeTrustERC721

Deploying new TradeTrustERC721
#### Deploy new token registry

```ts
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";
Expand All @@ -25,15 +28,15 @@ const factory = new TradeTrustERC721Factory(signer1);
const tokenRegistry = await tokenRegistryFactory.deploy("MY_TOKEN_REGISTRY", "TKN");
```

Connecting to existing TradeTrustERC721 on Ethereum
#### Connect to existing token registry

```ts
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";

const connectedRegistry = TradeTrustERC721Factory.connect(existingERC721Address, signer1);
```

List of available functions on TradeTrustERC721
#### List of available functions

The contract supports [all ERC721 methods](http://erc721.org/)

Expand All @@ -42,22 +45,24 @@ The contract supports [all ERC721 methods](http://erc721.org/)
The TradeTrustErc721 Token Registry will clone a new TitleEscrow internally when minting or restoring titles.

#### Minting Title Escrow

```ts
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";

const connectedRegistry = TradeTrustERC721Factory.connect(existingERC721Address, signer);
const tx = await connectedRegistry.mintTitle(beneficiaryAddress, holderAddress, tokenId);
````
```

#### Restoring Title Escrow

```ts
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";

const connectedRegistry = TradeTrustERC721Factory.connect(existingERC721Address, signer);
const tx = await connectedRegistry.restoreTitle(beneficiaryAddress, holderAddress, existingTokenId);
````
```

#### Connecting to an existing TitleEscrow on Ethereum
#### Connect to Title Escrow

```ts
import { TitleEscrowFactory } from "@govtechsg/token-registry";
Expand All @@ -67,12 +72,12 @@ const connectedEscrow = TitleEscrowFactory.connect(existingTitleEscrowAddress, s

For list of available functions on TitleEscrow simply check the type definitions as they are automatically generated using typechain.

## Provider & Signer
### Provider & Signer

Different ways to get provider or signer:

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

// Providers
const mainnetProvider = getDefaultProvider();
Expand All @@ -87,11 +92,6 @@ const signerFromMnemonic = Wallet.fromMnemonic("MNEMONIC-HERE");
signerFromMnemonic.connect(provider);
```


# Development
This repository's development framework uses (HardHat)[https://hardhat.org/getting-started/].

Tests are run using `npm run test`, more development tasks can be found in the package.json scripts.
## Setup

```sh
Expand All @@ -100,3 +100,9 @@ npm lint
npm test
npx hardhat <command>
```

## Development

This repository's development framework uses [HardHat](https://hardhat.org/getting-started/).

Tests are run using `npm run test`, more development tasks can be found in the package.json scripts.

0 comments on commit 93bff7e

Please sign in to comment.