Skip to main content

Feedback

Is this page helpful?

Version: 5.x

Issuing Documents (Code)

CLI

Code

CLI

Code

Overview

Deploying Document Store - CLI

Deploying Document Store - Code

Configuring DNS

Creating Raw Document

Wrapping Documents - CLI

Wrapping Documents - Code

Issuing Documents - CLI

Issuing Documents - Code

Revoking Documents - CLI

Revoking Documents - Code

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

Installation

npm install --save @trustvc/trustvc

Usage

To use the package, you will need to provide your own Web3 provider or signer (if you are writing to the blockchain).

Refer to the pre-requisite on document store deployment.

Issuing on document store

The TrustVC library provides a documentStoreIssue function that supports both ethers v5 and v6, and automatically detects the document store type (standard, transferable, or legacy TT document store).

import { documentStoreIssue } from "@trustvc/trustvc";
import { Wallet, ethers } from "ethers";

// Setup wallet and provider
const wallet = new Wallet("privateKey");
const provider = new ethers.JsonRpcProvider("https://sepolia.infura.io/v3/YOUR_INFURA_KEY");
const signer = wallet.connect(provider);

// Issue a document hash to the document store
const tx = await documentStoreIssue(
"0x63A223E025256790E88778a01f480eBA77731D04", // Document store address
"0x8dcf358a9436bca6654f565e3c5843d91c0052d3a2eff37bbd380038e8a1fa39", // Document hash (merkle root)
signer,
{
maxFeePerGas: "50000000000", // Optional: EIP-1559 gas settings
maxPriorityFeePerGas: "2000000000",
},
);

const receipt = await tx.wait();
console.log(`Document issued in transaction: ${receipt.hash}`);

Verify document issuance

After issuing, you can verify that the document has been issued:

import { DocumentStore__factory } from "@trustvc/trustvc";
import { Wallet, ethers } from "ethers";

const wallet = new Wallet("privateKey");
const provider = new ethers.JsonRpcProvider("https://sepolia.infura.io/v3/YOUR_INFURA_KEY");
const signer = wallet.connect(provider);

// Connect to the document store
const documentStore = DocumentStore__factory.connect(
"0x63A223E025256790E88778a01f480eBA77731D04",
signer
);

// Check if document is issued
const isIssued = await documentStore.isIssued(
"0x8dcf358a9436bca6654f565e3c5843d91c0052d3a2eff37bbd380038e8a1fa39"
);
console.log(`Has been Issued: ${isIssued}`); // Has been Issued: true

// Issue Transaction:
{
"to": "0x63A223E025256790E88778a01f480eBA77731D04",
"from": "0xe0A71284EF59483795053266CB796B65E48B5124",
"contractAddress": null,
"transactionIndex": 0,
"gasUsed": { "type": "BigNumber", "hex": "0xbb0e" },
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000040000000000000000000000000000000400000000000000000000000000000000000000800000000000010000000000000000",
"blockHash": "0x0c29e92cecf3086a4235d15c343bafcece6bc74dd90aab6cb00dbe712551fc6b",
"transactionHash": "0x9d06deed29d3f6f91143dcf2e5c9bf8551eb9d4d51601e85f607c9bce3c6a6d5",
"logs": [
{
"transactionIndex": 0,
"blockNumber": 4742643,
"transactionHash": "0x9d06deed29d3f6f91143dcf2e5c9bf8551eb9d4d51601e85f607c9bce3c6a6d5",
"address": "0x63A223E025256790E88778a01f480eBA77731D04",
"topics": [
"0x01a1249f2caa0445b8391e02413d26f0d409dabe5330cd1d04d3d0801fc42db3",
"0x8dcf358a9436bca6654f565e3c5843d91c0052d3a2eff37bbd380038e8a1fa39"
],
"data": "0x",
"logIndex": 0,
"blockHash": "0x0c29e92cecf3086a4235d15c343bafcece6bc74dd90aab6cb00dbe712551fc6b"
}
],
"blockNumber": 4742643,
"confirmations": 1,
"cumulativeGasUsed": { "type": "BigNumber", "hex": "0xbb0e" },
"effectiveGasPrice": { "type": "BigNumber", "hex": "0x01af7449c4" },
"status": 1,
"type": 2,
"byzantium": true,
"events": [
{
"transactionIndex": 0,
"blockNumber": 4742643,
"transactionHash": "0x9d06deed29d3f6f91143dcf2e5c9bf8551eb9d4d51601e85f607c9bce3c6a6d5",
"address": "0x63A223E025256790E88778a01f480eBA77731D04",
"topics": [
"0x01a1249f2caa0445b8391e02413d26f0d409dabe5330cd1d04d3d0801fc42db3",
"0x8dcf358a9436bca6654f565e3c5843d91c0052d3a2eff37bbd380038e8a1fa39"
],
"data": "0x",
"logIndex": 0,
"blockHash": "0x0c29e92cecf3086a4235d15c343bafcece6bc74dd90aab6cb00dbe712551fc6b",
"args": ["0x8dcf358a9436bca6654f565e3c5843d91c0052d3a2eff37bbd380038e8a1fa39"],
"event": "DocumentIssued",
"eventSignature": "DocumentIssued(bytes32)"
}
]
}

Please refer to Document-Store repository on other interfaces available on the smart contracts;

🎉 Congratulations, you have completed the getting started guide to create your first Verifiable Document!

Additional information: Revocation of Verifiable Documents

Revoking of Verifiable Documents