The 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
).
🧪 Join the Beta!
If you are interested in using and helping us at testing the new features of transferable records, please consider trying out our beta branch. We'd love to hear your feedback!😊
npm i @govtechsg/token-registry
To use the package, you will need to provide your own Web3 provider or signer (if you are writing to the blockchain).
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";
const factory = new TradeTrustERC721Factory(signer1);
const tokenRegistry = await tokenRegistryFactory.deploy("MY_TOKEN_REGISTRY", "TKN");
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";
const connectedRegistry = TradeTrustERC721Factory.connect(existingERC721Address, signer1);
The contract supports all ERC721 methods
The TradeTrustErc721 Token Registry will clone a new TitleEscrow internally when minting or restoring titles.
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";
const connectedRegistry = TradeTrustERC721Factory.connect(existingERC721Address, signer);
const tx = await connectedRegistry.mintTitle(beneficiaryAddress, holderAddress, tokenId);
import { TradeTrustERC721Factory } from "@govtechsg/token-registry";
const connectedRegistry = TradeTrustERC721Factory.connect(existingERC721Address, signer);
const tx = await connectedRegistry.restoreTitle(beneficiaryAddress, holderAddress, existingTokenId);
import { TitleEscrowFactory } from "@govtechsg/token-registry";
const connectedEscrow = TitleEscrowFactory.connect(existingTitleEscrowAddress, signer1);
For list of available functions on TitleEscrow simply check the type definitions as they are automatically generated using typechain.
Different ways to get provider or signer:
import { Wallet, providers, getDefaultProvider } from "ethers";
// Providers
const mainnetProvider = getDefaultProvider();
const ropstenProvider = getDefaultProvider("ropsten");
const metamaskProvider = new providers.Web3Provider(web3.currentProvider); // Will change network automatically
// Signer
const signerFromPrivateKey = new Wallet("YOUR-PRIVATE-KEY-HERE", provider);
const signerFromEncryptedJson = Wallet.fromEncryptedJson(json, password);
signerFromEncryptedJson.connect(provider);
const signerFromMnemonic = Wallet.fromMnemonic("MNEMONIC-HERE");
signerFromMnemonic.connect(provider);
npm install
npm lint
npm test
npx hardhat <command>
This repository's development framework uses HardHat.
Tests are run using npm run test
, more development tasks can be found in the package.json scripts.
- The contracts have not gone through formal audits yet. Please use them at your own discretion.