Migration to TrustVC
This migration guide will help you transition from using the TradeTrust libraries (@tradetrust-tt/tt-verify, @tradetrust-tt/tradetrust) to TrustVC. In addition, it introduces the new W3C Verifiable Credentials (VC) integration for managing verifiable credentials. This version of TrustVC integrates both token-based credentials and W3C VC to provide a unified credential management solution.
1. What’s New?
TrustVC Integration
- TrustVC is a comprehensive library that combines several TradeTrust libraries, including Token Registry v5, W3C Verifiable Credentials, and OpenAttestation Verifiable Documents. By using TrustVC, you can manage both credential documents and token-based credentials seamlessly in a unified solution.
Token Registry v5
- Token Registry v5 is the newest version. It allows you to manage token-based credentials and ownership transfers through smart contracts. For more information refer to here.
2. How to Migrate to TrustVC
To install the TrustVC library:
Run the following command in your project directory:
npm install @trustvc/trustvc
3. Code Migration
Wrapping OpenAttestation Document
Before Migration (using @tradetrust-tt/tradetrust):
import { wrapDocument } from '@tradetrust-tt/tradetrust';
const rawDocument = { /* document content */ };
const wrappedDocument = wrapDocument(rawDocument);
After Migration (using @trustvc/trustvc):
import { wrapOADocument } from '@trustvc/trustvc';
const rawDocument = { /* document content */ };
const wrappedDocument = await wrapOADocument(rawDocument);
Signing OpenAttestation Document
Before Migration (using @tradetrust-tt/tradetrust):
import { signDocument, SUPPORTED_SIGNING_ALGORITHM } from '@tradetrust-tt/tradetrust';
const wrappedDocument = { /* document content */ };
const signedWrappedDocument = await signDocument(wrappedDocument, SUPPORTED_SIGNING_ALGORITHM.Secp256k1VerificationKey2018, {
public: 'did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90#controller',
private: '<privateKey>',
});
After Migration (using @trustvc/trustvc):
import { signOA } from '@trustvc/trustvc';
const wrappedDocument = { /* document content */ };
const signedWrappedDocument = await signOA(wrappedDocument, {
public: 'did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90#controller',
private: '<privateKey>',
});
Signing W3C Document
The TrustVC W3C Signing feature simplifies the signing process for W3C-compliant verifiable credentials using BBS+ signatures. This feature allows you to easily sign W3C Verifiable Credentials (VCs) and ensure they comply with the latest standards.
Signing W3C Document (using @trustvc/trustvc):
import { signW3C, VerificationType } from '@trustvc/trustvc';
const rawDocument = { /* document content */ };
const signingResult = await signW3C(rawDocument, {
id: 'did:web:trustvc.github.io:did:1#keys-1',
controller: 'did:web:trustvc.github.io:did:1',
type: VerificationType.Bls12381G2Key2020,
publicKeyBase58: '<publicKeyBase58>',
privateKeyBase58: '<privateKeyBase58>',
});
Verifying Document
TrustVC simplifies the verification process with a single function that supports both W3C Verifiable Credentials (VCs) and OpenAttestation Verifiable Documents (VDs). Whether you're working with W3C standards or OpenAttestation standards, TrustVC handles the verification seamlessly.
Before Migration (using @tradetrust-tt/tt-verify):
import { verify } from "@tradetrust-tt/tt-verify";
const signedDocument = { /* document content */ };
const resultFragments = await verify(signedDocument);
After Migration (using @trustvc/trustvc):
import { verifyDocument } from '@trustvc/trustvc';
const signedDocument = { /* document content */ };
const resultFragments = await verifyDocument(signedDocument);
Token Registry V5
To dive deeper into the new features of Token Registry v5, refer to the following pages:
- Token Registry v5 Overview – Detailed documentation on the new methods and enhancements.
- Token Registry v5 Migration Guide – Step-by-step guide for migrating your codebase to Token Registry v5.