diff --git a/README.md b/README.md index d2f05ba9..db399322 100644 --- a/README.md +++ b/README.md @@ -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"; @@ -25,7 +28,7 @@ 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"; @@ -33,7 +36,7 @@ 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/) @@ -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"; @@ -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(); @@ -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 @@ -100,3 +100,9 @@ npm lint npm test npx hardhat ``` + +## 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.