### Create Project Directory (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Creates a new directory for the verifier project and navigates into it. ```bash mkdir verifier-project cd verifier-project ``` -------------------------------- ### Initialize npm Project (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Initializes a new npm project, creating a package.json file. ```bash npm init -y ``` -------------------------------- ### Project Structure Setup Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/transferability.md Defines the basic directory and file structure for a TradeTrust project, including source files and the main HTML entry point. ```bash ├── src │ ├── app.tsx │ ├── assetManagement.tsx │ ├── endorsementChain.tsx │ └── main.tsx └── index.html ``` -------------------------------- ### Install Dependencies (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Installs necessary project dependencies, including React, Vite plugins, TrustVC, and TypeScript development tools. ```bash npm install react react-dom vite-plugin-node-polyfills @trustvc/trustvc npm install --save-dev typescript @vitejs/plugin-react @types/react @types/react-dom ``` -------------------------------- ### Command to Run Vite Development Server Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/transferability.md The command to execute to start the Vite development server, making the Transferability app accessible in the browser. ```bash npm run dev ``` -------------------------------- ### Setup TradeTrust Development Environment Source: https://github.com/tradetrust/documentation/blob/master/docs/community/contributing.md This snippet shows the basic commands to clone the TradeTrust repository, navigate into the project directory, and install the necessary dependencies using npm. ```sh git clone https://github.com/trustvc/trustvc.git cd trustvc npm install ``` -------------------------------- ### Add Basic Project Structure Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Sets up the fundamental files and folders for a React-based document verifier project. Includes the main application component (App.tsx), the entry point (main.tsx), and basic styling (index.css). ```bash src/ ├── App.tsx ├── main.tsx └── index.css ``` -------------------------------- ### Create HTML File for Verifier App Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Defines the basic HTML structure for the verifier application. It includes a title, a root div for React mounting, and a script tag to load the main application entry point. ```html Verifier
``` -------------------------------- ### Set Up React Application Entry Point Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Configures the main entry point for the React application using ReactDOM. It renders the App component within a React.StrictMode and applies global styles from index.css. ```tsx import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; import './index.css'; ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( ); ``` -------------------------------- ### Configure Vite Development Server Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Adds a 'dev' script to the package.json file to run the Vite development server. This allows for efficient local development and testing of the application. ```json { "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "vite" } } ``` -------------------------------- ### Setup Project Dependencies for W3C VC Document Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/create-w3c-document.md This snippet shows how to set up a new project, initialize it with npm, and install necessary dependencies for creating W3C VC documents using TradeTrust. It includes installing core libraries like `@trustvc/trustvc` and `ethers`, along with development dependencies for TypeScript. ```bash mkdir w3c-document-demo cd w3c-document-document npm init -y npm install npx tsc --init ``` -------------------------------- ### Install Open Attestation Source: https://github.com/tradetrust/documentation/blob/master/versioned_docs/version-4.x/reference/libraries/oa.md Installs the Open Attestation package using npm. This is the first step to using the library in your project. ```bash npm i @govtechsg/open-attestation ``` -------------------------------- ### Install TradeTrust CLI using NPM Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/open-attestation/prerequisites.md Installs the TradeTrust CLI globally on Linux or MacOS using npm. Requires Node.js to be installed. ```bash npm install -g @tradetrust-tt/tradetrust-cli ``` -------------------------------- ### TradeTrust Core Library Source: https://github.com/tradetrust/documentation/blob/master/versioned_docs/version-4.x/getting-started/getting-started.md This section refers to the TradeTrust Core library, which is a fundamental component for building TradeTrust applications. It likely contains the essential functions and data structures for interacting with the TradeTrust network. ```N/A TradeTrust [Core](/docs/4.x/reference/libraries/tt-core) ``` -------------------------------- ### Install CLI for did:web Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/issuer/did-web.md Installs the TrustVC CLI globally, which is recommended for generating `did:web` DID documents and key pairs. ```bash npm install -g @trustvc/w3c-cli ``` -------------------------------- ### Setup Project Dependencies (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/advanced/aws-kms/kms-mint-demo.md Initializes a new Node.js project and installs necessary dependencies including @trustvc/trustvc, ethers.js v5, and dotenv for managing environment variables. ```bash mkdir aws-kms-mint-demo cd aws-kms-mint-demo npm init -y npm install ``` -------------------------------- ### Install TrustVC Library Source: https://github.com/tradetrust/documentation/blob/master/docs/migration-guide/migration-trustvc.md Installs the TrustVC library using npm. This is the first step in migrating to TrustVC. ```bash npm install @trustvc/trustvc ``` -------------------------------- ### Install tradetrust-cli via npm Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/deployment.md Installs the TradeTrust CLI globally on Linux or MacOS using npm. Requires Node.js to be installed. ```bash npm install -g @tradetrust-tt/tradetrust-cli ``` -------------------------------- ### Install TradeTrust CLI Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/open-attestation/verifiable-documents/dns-did/wrapping-document/wrapping-document-code.mdx Installs the TradeTrust CLI tool, which is used for various document operations including wrapping. ```bash npm install @trustvc/trustvc ``` -------------------------------- ### Install Dependencies (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/transferability.md Installs the necessary project dependencies, including React, Vite plugins, TrustVC library, and TypeScript development tools. It separates production and development dependencies. ```bash npm install react react-dom vite-plugin-node-polyfills @trustvc/trustvc ethers npm install --save-dev typescript @vitejs/plugin-react @types/react @types/react-dom ``` -------------------------------- ### Initialize TypeScript (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Initializes TypeScript configuration by creating a tsconfig.json file. ```bash npx tsc --init ``` -------------------------------- ### Get Stability Protocol API Key Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/advanced/additional-network-metamask-guide.mdx This section guides users to obtain an API key from Stability Protocol. It directs users to follow Stability's official guide for the registration process. ```English Follow [Stability's guide](https://docs.stabilityprotocol.com/developers/register_for_api_key) to sign up for a Stability Protocol's API Key ``` -------------------------------- ### Deploy Document Store - CLI Source: https://github.com/tradetrust/documentation/blob/master/versioned_docs/version-4.x/tutorial/verifiable-documents/advanced/document-store/flow.mdx Instructions for deploying the TradeTrust Document Store using the Command Line Interface (CLI). This section covers the initial setup and deployment steps. ```cli deploying-document-store-cli ``` -------------------------------- ### Run the App Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/creator.md Command to start the development server for the TradeTrust application. ```bash npm run dev ``` -------------------------------- ### Vite Configuration (TypeScript) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Configures Vite as the build tool, enabling React support and Node.js polyfills. ```typescript import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { nodePolyfills } from 'vite-plugin-node-polyfills'; export default defineConfig({ plugins: [ react(), nodePolyfills() ], }); ``` -------------------------------- ### v2.0 Credential with Status List Example Source: https://github.com/tradetrust/documentation/blob/master/docs/migration-guide/w3c-vc-v2.md Presents an example of a Verifiable Credential in v2.0 format, including a `credentialStatus` property that points to a BitstringStatusListEntry. It specifies the v2.0 context, types, and status details. ```typescript const credentialWithStatusV2 = { '@context': [ 'https://www.w3.org/ns/credentials/v2', 'https://w3id.org/security/data-integrity/v2' ], type: ['VerifiableCredential'], issuer: 'did:web:example.com', validFrom: '2024-01-01T00:00:00Z', credentialStatus: { id: 'https://example.com/status/1#42', type: 'BitstringStatusListEntry', // v2.0 status type statusPurpose: 'revocation', statusListIndex: '42', statusListCredential: 'https://example.com/status/1' }, credentialSubject: { id: 'did:example:subject', name: 'John Doe' } }; ``` -------------------------------- ### v1.1 Credential with Status List Example Source: https://github.com/tradetrust/documentation/blob/master/docs/migration-guide/w3c-vc-v2.md Provides an example of a Verifiable Credential in v1.1 format that includes a `credentialStatus` property referencing a StatusList2021Entry. It outlines the necessary context, types, and status details. ```typescript const credentialWithStatusV1 = { '@context': [ 'https://www.w3.org/2018/credentials/v1', 'https://w3id.org/security/bbs/v1', 'https://w3id.org/vc/status-list/2021/v1' ], type: ['VerifiableCredential'], issuer: 'did:web:example.com', issuanceDate: '2024-01-01T00:00:00Z', credentialStatus: { id: 'https://example.com/status/1#42', type: 'StatusList2021Entry', // v1.1 status type statusPurpose: 'revocation', statusListIndex: '42', statusListCredential: 'https://example.com/status/1' }, credentialSubject: { id: 'did:example:subject', name: 'John Doe' } }; ``` -------------------------------- ### Create Project Directory (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/transferability.md Creates a new directory for the project and navigates into it. This is the initial step for setting up the project environment. ```bash mkdir transferability-project cd transferability-project ``` -------------------------------- ### TradeTrust CLI Wallet Creation Output Source: https://github.com/tradetrust/documentation/blob/master/versioned_docs/version-4.x/tutorial/prerequisites.md Example output from the TradeTrust CLI after successfully creating a wallet, showing the process and the saved file location. ```text ℹ info Creating a new wallet ? Wallet password [hidden] … awaiting Encrypting Wallet [====================] [100/100%] ℹ info Wallet with public address 0x10cFd56E11e7d66C8d0716Cd2D6B847Cb17ABeeD successfully created. Find more details: ✔ success Wallet successfully saved into /home/nebulis/IdeaProjects/open-attestation-cli/wallet.json ``` -------------------------------- ### TradeTrust CLI Wallet Creation Output Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/open-attestation/prerequisites.md Example output from the TradeTrust CLI after successfully creating a wallet, showing the process and the saved file location. ```text ℹ info Creating a new wallet ? Wallet password [hidden] … awaiting Encrypting Wallet [====================] [100/100%] ℹ info Wallet with public address 0x10cFd56E11e7d66C8d0716Cd2D6B847Cb17ABeeD successfully created. Find more details: ✔ success Wallet successfully saved into /home/nebulis/IdeaProjects/open-attestation-cli/wallet.json ``` -------------------------------- ### TypeScript Configuration (JSON) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Defines the TypeScript compiler options for the project, including target, module, JSX, strictness, module resolution, and module interop. ```json { "compilerOptions": { "target": "ES2020", "module": "ESNext", "jsx": "react", "strict": true, "moduleResolution": "Node", "esModuleInterop": true, "skipLibCheck": true }, "include": ["src"], "exclude": ["node_modules"] } ``` -------------------------------- ### Start Local Development Server Source: https://github.com/tradetrust/documentation/blob/master/README.md Starts a local development server for the website. Changes are reflected live without requiring a server restart, facilitating rapid development. ```bash npm run start ``` -------------------------------- ### Execute Deployment Scripts Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/creator.md These bash commands demonstrate how to run the previously defined npm scripts to generate DID web documents and deploy the Token Registry contract. Ensure that the `.env` file is correctly configured with necessary API keys and wallet information. ```bash npm run script:generateDidWeb npm run script:deployTokenRegistry ``` -------------------------------- ### Run Development Preview Source: https://github.com/tradetrust/documentation/blob/master/versioned_docs/version-4.x/tutorial/decentralised-renderer/decentralised-renderer.md Starts the development server for the decentralized renderer using Storybook, allowing for live preview and editing of templates. ```sh npm run storybook ``` -------------------------------- ### Update TrustVC Dependencies Source: https://github.com/tradetrust/documentation/blob/master/docs/migration-guide/w3c-vc-v2.md Installs the latest version of the TrustVC library that supports W3C VC Data Model v2.0. ```bash npm install @trustvc/trustvc@latest ``` -------------------------------- ### TradeTrust Verifier Library Source: https://github.com/tradetrust/documentation/blob/master/versioned_docs/version-4.x/getting-started/getting-started.md This section points to the TradeTrust Verifier library, designed for verifying the authenticity and integrity of documents within the TradeTrust ecosystem. It's crucial for ensuring data trustworthiness. ```N/A TradeTrust [Verifier](/docs/4.x/reference/libraries/tt-verify) ``` -------------------------------- ### Install Dependencies Source: https://github.com/tradetrust/documentation/blob/master/README.md Installs the necessary project dependencies using npm. This is the first step before running the development server or building the project. ```bash npm install ``` -------------------------------- ### Verifying Documents and Checking Validity with TrustVC Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Shows how to use the `verifyDocument` function to process a document against a list of verifiers and then use the `isValid` function to determine the overall validity of the document based on different criteria. ```JavaScript import { isValid, verifyDocument } from "@trustvc/trustvc"; import * as document from "./document.json"; // RPC provider url for interacting with any supported blockchain const rpc = "any supported blockchain"; const fragments = await verifyDocument(document, rpc); console.log(isValid(fragments, ["DOCUMENT_INTEGRITY"])); console.log(isValid(fragments, ["DOCUMENT_STATUS"])); console.log(isValid(fragments, ["ISSUER_IDENTITY"])); console.log(isValid(fragments)); ``` -------------------------------- ### Initialize npm Project (Bash) Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/transferability.md Initializes a new Node.js project by creating a package.json file. This command sets up the project for package management. ```bash npm init -y ``` -------------------------------- ### Build OpenAttestation Verifier - TypeScript Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Constructs a verification function specifically for OpenAttestation documents using a predefined set of OpenAttestation verifiers and an Ethereum provider. This function validates document integrity, authenticity, and status. ```typescript import { verificationBuilder, openAttestationVerifiers } from "@trustvc/trustvc"; import { ethers } from "ethers"; // Provider configuration for interacting with the Amoy blockchain const provider = new ethers.providers.JsonRpcProvider("https://rpc-amoy.polygon.technology"); /** * Verification function for OpenAttestation (OA) documents. * Uses OpenAttestation verifiers to validate the integrity, authenticity, and status of OA documents. * Equivalent to the default OA verifier provided by TrustVC. */ const verifyOA = verificationBuilder(openAttestationVerifiers, { provider }); ``` -------------------------------- ### Full CLI Signing Interaction Example Source: https://github.com/tradetrust/documentation/blob/master/docs/introduction/key-components-of-tradetrust/w3c-vc/signing-documents/signing-document-cli.mdx A complete example demonstrating the interactive prompts and responses when using the 'w3c-cli sign' command. ```bash $ w3c-cli sign ? Please enter the path to your key pair JSON file: ./didKeyPairs.json ? Please enter the path to your credential JSON file: ./vc.json ? Please specify a directory path to save your signed verifiable credential: . Signed credential saved successfully to ./signed_vc.json ``` -------------------------------- ### Run TradeTrust CLI with NPX Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/open-attestation/prerequisites.md Executes the TradeTrust CLI using npx, allowing you to run commands without global installation. Replace '' with desired CLI commands. ```bash npx -p @tradetrust-tt/tradetrust-cli tradetrust ``` -------------------------------- ### Template Name Matching Example Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/decentralized-renderer/decentralized-renderer-guide.md This JavaScript snippet illustrates the correct way to match template names between a TradeTrust document's `renderMethod` and a template registry. It highlights the importance of case-sensitive matching for the `templateName` field. ```javascript // Document { "renderMethod": [ { "id": "http://localhost:3000", "type": "EMBEDDED_RENDERER", "templateName": "BILL_OF_LADING" } ] } // Template Registry export const registry = { "BILL_OF_LADING": BillOfLadingTemplate, // Must match templateName in renderMethod // ... }; ``` -------------------------------- ### Verify TradeTrust CLI Installation Source: https://github.com/tradetrust/documentation/blob/master/docs/how-tos/open-attestation/prerequisites.md Checks if the TradeTrust CLI is installed and accessible by displaying its version. Ensure 'tradetrust' is in your PATH or use the full executable path. ```bash tradetrust --version ``` -------------------------------- ### Building a Verification Function with Custom Verifiers Source: https://github.com/tradetrust/documentation/blob/master/docs/tutorial/verifier.md Demonstrates how to create a verification function using `verificationBuilder`, combining default OpenAttestation verifiers with a custom one. It also shows how to execute the verification and check the validity of the resulting fragments. ```TypeScript import { verificationBuilder, openAttestationVerifiers, Verifier, isValid, getDataV2 } from "@trustvc/trustvc"; import { ethers } from "ethers"; import document from "./document.json"; // Provider configuration for interacting with the Amoy blockchain const provider = new ethers.providers.JsonRpcProvider("https://rpc-amoy.polygon.technology"); const customVerifier: Verifier = { /* content has been defined in the section above */ }; // create your own verify function with all verifiers and your custom one const verify = verificationBuilder([...openAttestationVerifiers, customVerifier], { provider }); const fragments = await verify(document); console.log(isValid(fragments)); console.log(fragments.find((fragment: any) => fragment.name === "CustomVerifier")); // display the details on our specific verifier ```