Get Started with the Trust Engine SDK

Welcome to the official documentation for the Trust Engine SDK. This guide will help you quickly get started with the core functionalities of the SDK, allowing you to integrate file registration, verification, and wallet management into your applications with ease.

Installation

To get started, install the SDK using npm:
npm install @trust-engine/sdk@latest

Quick Start

Here’s a quick example of how to import and use the SDK in your project:
import { TrustEngineSDK } from '@trust-engine/sdk';

// Initialize the SDK
const sdk = new TrustEngineSDK();

// Example: Create a new wallet
async function createNewWallet() {
  try {
    const result = await sdk.createWallet({ userID: 'new-user-123' });
    console.log('Wallet created:', result.details.walletAddress);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

createNewWallet();

Core Functions

Here is a brief overview of the core functions available in the SDK:

Create a Wallet

Create a new Solana wallet for a user.
const { walletAddress } = await sdk.createWallet({ userID: 'user-id-123' });

Register a File

Register a file on the blockchain to create an immutable record.
const file = new File(["content"], "example.txt", { type: "text/plain" });
const result = await sdk.registerFile({
  file,
  contentTitle: 'My Document',
  walletAddress: 'YOUR_WALLET_ADDRESS',
  walletType: 'managed',
});

Search for a File

Search for a file’s registration record using the file itself.
const file = new File(["content"], "example.txt", { type: "text/plain" });
const records = await sdk.searchFile({ file });

Verify Identity

Initiate identity verification for a wallet address using Self.xyz ZK verification.
const result = await sdk.verifyIdentity({
  walletAddress: 'YOUR_WALLET_ADDRESS',
  disclosures: {
    issuing_state: false,
    name: true,
    nationality: true,
    date_of_birth: true,
    passport_number: false,
    gender: false,
    expiry_date: false
  }
});

Check Identity Status

Monitor the status of an identity verification session.
const status = await sdk.checkIdentityStatus('YOUR_WALLET_ADDRESS');
console.log('Verification status:', status.details.status);

Explore the functions in the sidebar to learn more about each feature.