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 #48

Merged
merged 1 commit into from
Nov 10, 2021
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
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.