Skip to main content

Feedback

Is this page helpful?

Version: 5.x

Deploying Document Store Smart Contract (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 @trustvc/document-store

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 setup instructions.

Deploy new document store

The TrustVC library supports both ethers v5 and v6.

The examples below use ethers v6 syntax (ethers.JsonRpcProvider ). If you are using ethers v5, replace it with ethers.providers.JsonRpcProvider(...) .

It also provides two types of document stores:

  1. Standard Document Store (default): For immutable documents that cannot be transferred
  2. Transferable Document Store: For documents that can change ownership
import { deployDocumentStore, CHAIN_ID } 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);
const walletAddress = await signer.getAddress();

// Deploy standard document store
const receipt = await deployDocumentStore(
"My Document Store",
walletAddress,
signer,
{
chainId: CHAIN_ID.SEPOLIA,
maxFeePerGas: "50000000000", // Optional: EIP-1559 gas settings
maxPriorityFeePerGas: "2000000000"
}
);

console.log(`Document Store deployed at: ${receipt.contractAddress}`);
// Document Store deployed at: 0x63A223E025256790E88778a01f480eBA77731D04

Deploy transferable document store

For documents that need to support ownership transfers:

import { deployDocumentStore, CHAIN_ID } 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);
const walletAddress = await signer.getAddress();

// Deploy transferable document store
const receipt = await deployDocumentStore(
"My Transferable Document Store",
walletAddress,
signer,
{
chainId: CHAIN_ID.SEPOLIA,
isTransferable: true // Enable transferability
}
);

console.log(`Transferable Document Store deployed at: ${receipt.contractAddress}`);

Connect to existing document store

import { DocumentStore__factory } from "@trustvc/document-store";
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 existing document store
const documentStore = DocumentStore__factory.connect(
"0x63A223E025256790E88778a01f480eBA77731D04",
signer
);

console.log(`Document Store Name: ${await documentStore.name()}`);
// Document Store Name: My Document Store

Congratulations! You have successfully deployed a document store.

Next we take a look at configuring the DNS.