didPass
didPass Developer's Guide
didPass Developer's Guide
  • getting started
    • 👋Welcome to didPass
    • 📘Introduction
    • 🔺Triangle of Trust
    • ⚡Quickstart
      • Issuer - Typescript/Node.js
      • Verifier - Typescript/Node.js
      • Installing The SDK
  • Issuer
    • 📋Requirements
    • 🔧Installation
    • 💻Sample Code
      • Connecting Wallet with Issuer
        • Request Connect QR Code
        • Authenticate with Signature
      • Download Verifiable Credential
        • Generating QR Code for Claiming VC
        • Claiming and Signing Credential
      • Download Jws Credential
        • Generating QR Code for Claiming JWS Credential
        • Claiming JWS Credential
    • API References
  • Verifier
    • 📃Requirements
    • 🛠️Installation
    • 👨‍💻Sample Code
      • Prerequisite
      • Generating QR Code for DVR
      • Generating Signed DVR Token
      • Verifying Siwe
      • Verifying Proof
    • API References
  • Wallet
    • ✅Requirements
    • 📥Installation
    • 🖥️Sample Code
    • API References
  • References
    • didPass User's Guide
    • zkPass User's Guide
    • zkPass Developer's Guide
Powered by GitBook
On this page
  • Demo Application
  • Importing Classes
  • Creating a Wallet Instance
  • Wallet Creation
  • Wallet Import
  • Wallet Recovery
  • Wallet Deletion
  1. Wallet

Sample Code

Demo Application

Importing Classes

Start by importing the necessary classes from the SDK in your JavaScript file:

import Wallet from 'didpass-wallet-sdk';

Creating a Wallet Instance

Create a new instance of the Wallet class using the create static method. Provide the authServerBaseUrl and a storage instance implementing the IStorage interface:

const authServerBaseUrl: string = "YOUR_AUTH_SERVER_BASE_URL";
const storage: IStorage = // Your implementation of the IStorage interface

const wallet: Wallet = Wallet.create(authServerBaseUrl, storage);

Here is an example implementation of IStorage written in React Native

import { IStorage } from 'didpass-wallet-sdk';

class SecureStorage implements IStorage {
  async get<T>(key: string): Promise<T | null> {
    const result = await SecureStore.getItemAsync(key);
    if (result) {
      return JSON.parse(result) as T;
    } else {
      return null;
    }
  }

  async set<T>(key: string, value: T): Promise<void> {
    await SecureStore.setItemAsync(key, JSON.stringify(value));
  }

  async remove(key: string): Promise<void> {
    await SecureStore.deleteItemAsync(key);
  }
}

Wallet Creation

Creates a new ethereum wallet.

const result = await wallet.walletManagement.createWallet({
  deviceId: deviceId,
  token
});

Wallet Import

Handle to bring your wallet you already have.

const result = await wallet.walletManagement.importWallet({
  deviceId,
  token,
  mnemonic
});

Wallet Recovery

Handle to recover your lost a wallet by recovering it.

const result = await wallet.walletManagement.recoverWallet({
  deviceId,
  token,
  spk,
  shares
});

Wallet Deletion

Handle deletion of your existing wallet.

await wallet.walletManagement.deleteWallet({
  deviceId,
  token
  spk
});

With the Wallet instance created, you have access to various functionalities.

PreviousInstallation

Last updated 1 year ago

🖥️