Skip to main content

Feedback

Loading...

Minting of the Document (Code)

For the current step, you can either opt to use the CLI or Code.

In this final step, we will mint the transferable record and initialize the first owner and holder for the title escrow.

Installation

npm install --save @tradetrust-tt/tradetrust-core

Usage

To use the package, you will need to provide your own Web3 provider or signer.

Refer to the pre-requisite on token registry deployment.

Connect to existing token registry

import { TradeTrustToken__factory } from "@tradetrust-tt/tradetrust-core";

const privateKey = "";
const tokenRegistryAddress = "0x7Ae2aE35f66ACE6671CB2bfb985011b0a2d9cf72";

const unconnectedWallet = new Wallet(privateKey);
const provider = ethers.getDefaultProvider("sepolia");
const wallet = unconnectedWallet.connect(provider);

const connectedRegistry = TradeTrustToken__factory.connect(tokenRegistryAddress, wallet);

Minting a Transferable Record

In the example, we will use 0x6FFeD6E6591b808130a9b248fEA32101b5220eca wallet address as owner and holder. You will need to replace this value with a wallet address you control to be able to perform different actions on the transferable records later.

import { TradeTrustToken__factory } from "@tradetrust-tt/tradetrust-core";

const privateKey = "";
const tokenRegistryAddress = "0x7Ae2aE35f66ACE6671CB2bfb985011b0a2d9cf72";
const owner = "0x6FFeD6E6591b808130a9b248fEA32101b5220eca";
const holder = "0x6FFeD6E6591b808130a9b248fEA32101b5220eca";
const tokenId = "0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea";

const unconnectedWallet = new Wallet(privateKey);
const provider = ethers.getDefaultProvider("sepolia");
const wallet = unconnectedWallet.connect(provider);

const connectedRegistry = TradeTrustToken__factory.connect(tokenRegistryAddress, wallet);
const tx = await connectedRegistry.mint(owner, holder, tokenId);
const receipt = await tx.wait();
console.log(`Receipt: ${JSON.stringify(receipt)}`);

Note to replace the following values:

  • Token Registry Address: 0x8431012Bc040942B59e3C5bf428221eab0b2f723 with your token registry contract address
  • Merkle Root: 0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea with your merkle root (with a 0x prefix)
  • Owner: 0x6FFeD6E6591b808130a9b248fEA32101b5220eca with your owner wallet addresses
  • Holder: 0x6FFeD6E6591b808130a9b248fEA32101b5220eca with your holder wallet addresses

Once the document has been issued, you will be able to see an output similar to the following:

{
"to": "0x7Ae2aE35f66ACE6671CB2bfb985011b0a2d9cf72",
"from": "0xE94E4f16ad40ADc90C29Dc85b42F1213E034947C",
"contractAddress": null,
"transactionIndex": 9,
"gasUsed": { "type": "BigNumber", "hex": "0x03fadd" },
"logsBloom": "0x08000000000000000880000000000000000000000004000000000000000000000000000020000000000000000000000000000000000000000000000000040820000000000000000000000008000000040008400020040000000000000201000008400000020000000000000000000800040000000000000000010010000000000000000040000000000000800000000000000040000000000000400880800000000000000100000400000000000420000000000000001000000000040000000400000002000000000000000000000020000000000000000000000000010060000010000000001000000000000000000000100000000000000000000000000000",
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0",
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"logs": [
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5aA71Cc9559bC5e54E9504a81496d9F8454721F5",
"topics": [
"0xb0bd455d052e922edbbe2a529486dc0e6d64ed15f689ed2f018684d5dbfbf994",
"0x0000000000000000000000005d2de591aeef0cd3a9c1b73b31693d461d1ef16f",
"0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf72",
"0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea"
],
"data": "0x",
"logIndex": 22,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x7Ae2aE35f66ACE6671CB2bfb985011b0a2d9cf72",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000005d2de591aeef0cd3a9c1b73b31693d461d1ef16f",
"0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea"
],
"data": "0x",
"logIndex": 23,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0x07d0a1a2d5c465ecdf26fb8dda217b10270d8e11ff892df33f73ea690b8cd9b4",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 24,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0x88a734f529b322845e21a8ea2512c4fd613d73ef43deb62d5c790a1b8037bd21",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 25,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0xfebadd5e06bc3e2885248448caca94df39be7cf7fde139b4586ac7b92dfe70b2",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 26,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0xeac1fdedeedd55f76e4c4a4b9a1b485e1f324cccf90f5aac11af3eb172876049",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6",
"0x0000000000000000000000000000000000000000000000000000000000000001"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 27,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
}
],
"blockNumber": 4748935,
"confirmations": 1,
"cumulativeGasUsed": { "type": "BigNumber", "hex": "0x153a51" },
"effectiveGasPrice": { "type": "BigNumber", "hex": "0x5e71b3ff" },
"status": 1,
"type": 2,
"byzantium": true,
"events": [
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5aA71Cc9559bC5e54E9504a81496d9F8454721F5",
"topics": [
"0xb0bd455d052e922edbbe2a529486dc0e6d64ed15f689ed2f018684d5dbfbf994",
"0x0000000000000000000000005d2de591aeef0cd3a9c1b73b31693d461d1ef16f",
"0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf72",
"0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea"
],
"data": "0x",
"logIndex": 22,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x7Ae2aE35f66ACE6671CB2bfb985011b0a2d9cf72",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000005d2de591aeef0cd3a9c1b73b31693d461d1ef16f",
"0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea"
],
"data": "0x",
"logIndex": 23,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0",
"args": [
"0x0000000000000000000000000000000000000000",
"0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
{ "type": "BigNumber", "hex": "0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea" }
],
"event": "Transfer",
"eventSignature": "Transfer(address,address,uint256)"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0x07d0a1a2d5c465ecdf26fb8dda217b10270d8e11ff892df33f73ea690b8cd9b4",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 24,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0x88a734f529b322845e21a8ea2512c4fd613d73ef43deb62d5c790a1b8037bd21",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 25,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0xfebadd5e06bc3e2885248448caca94df39be7cf7fde139b4586ac7b92dfe70b2",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 26,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
},
{
"transactionIndex": 9,
"blockNumber": 4748935,
"transactionHash": "0x89e18892a03e3dd1f983a1e3eccaba65fd5b4938cb7926606d682fc7d6030fe6",
"address": "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F",
"topics": [
"0xeac1fdedeedd55f76e4c4a4b9a1b485e1f324cccf90f5aac11af3eb172876049",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6",
"0x0000000000000000000000008d366250a96debe81c8619459a503a0eebe33ca6",
"0x0000000000000000000000000000000000000000000000000000000000000001"
],
"data": "0x0000000000000000000000007ae2ae35f66ace6671cb2bfb985011b0a2d9cf720d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ec",
"logIndex": 27,
"blockHash": "0x0bb04ba3aad9f7e3812b9f2be6f60b1935853506c1bb6dd6aa1b4cd8cd84bdb0"
}
]
}

🎉 Congratulations, you have completed the getting started guide and minted your first transferable record.

Verifying your transferable record

To verify your transferable record, simply head over the https://dev.tradetrust.io/verify. You will be able to drop your transferable record (found in wrapped-documents folder from the previous steps) into the dropzone and see something similar to the following:

Completed Transferable Record

Notice you are able to click on Connect Wallet when logged in to either the owner or holder to gain access to actions to change the ownership and holdership of the transferable record.

Managing Title Escrows

The Title Escrow contract is used to manage and represent the ownership of a token between an owner and a holder. During minting, the Token Registry will create and assign a Title Escrow as the owner of that token. The actual owners will use the Title Escrow contract to perform their ownership operations, we call it title transfer actions.

Retrieving Title Escrow address from Token Registry

const privateKey = "";
const tokenRegistryAddress = "0x7Ae2aE35f66ACE6671CB2bfb985011b0a2d9cf72";
const tokenId = "0x0d9839a8034cb783d98bd57bcbaafb4dc3614c4193d2edf8a655c1ec6635b7ea";

const unconnectedWallet = new Wallet(privateKey);
const provider = ethers.getDefaultProvider("sepolia");
const wallet = unconnectedWallet.connect(provider);

const connectedRegistry = TradeTrustToken__factory.connect(tokenRegistryAddress, wallet);

const titleEscrowAddress = await connectedRegistry.ownerOf(tokenId);
console.log(`Title Escrow Address: ${titleEscrowAddress}`); // Title Escrow Address: "0x5D2de591aEef0cd3a9c1b73B31693d461d1ef16F"

const connectedEscrow = TitleEscrow__factory.connect(titleEscrowAddress, wallet);

console.log(`isHoldingToken: ${await connectedEscrow.isHoldingToken()}`); // isHoldingToken: true
console.log(`Token Registry: ${await connectedEscrow.registry()}`); // Token Registry: "0x7Ae2aE35f66ACE6671CB2bfb985011b0a2d9cf72"
console.log(`Owner: ${await connectedEscrow.beneficiary()}`); // Owner: "0x6FFeD6E6591b808130a9b248fEA32101b5220eca"
console.log(`Holder: ${await connectedEscrow.holder()}`); // Holder: "0x6FFeD6E6591b808130a9b248fEA32101b5220eca"

Additional information: Title Transfer actions

Title Transfer actions