Quick Start

This guide is designed to help you swiftly integrate wallet functionalities into your application. Follow the steps below to set up and start using the Wallet class.

Good to know: A quick start guide is handy to get you swiftly integrated with the Wallet SDK, allowing you to leverage wallet functionalities in your application. Whether you're a meticulous documentation reader or a dive-right-in developer, this guide is designed to give you the basics and get you up and running!

Install Wallet SDK

The best way to interact with our API is to use one of our official libraries:

# Install via NPM
npm install didpass-wallet-sdk

Importing Classes

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

import Wallet from '@sdk/src/services/Wallet';
import { IStorage } from './interfaces/IStorage';

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 '@sdk/src/services/interfaces/IStorage';

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 result.walletManagement.createWallet({
  deviceId: deviceId,
  token
});

Wallet Import

Handle to bring your wallet you already have.

const result = await result.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
});

Utilizing the Wallet Instance

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

  • Wallet Management: Facilitate the creation of new wallets with the walletManagement property.

  • Wallet Login: Manage user login into wallets using the walletLogin property.

  • User Info: Manage user info of wallet using the userInfo property.

  • Storage: Access the storage instance implementing the IStorage interface through the storage property.

  • SIWE Services: Manage Sign In With Ethereum services using the siweServiceClient property.

  • ZkPass Client: Manage Generate ZkPass Proof Token services using the zkPassClient property.

  • Authentication: This is an advanced feature. Utilize authentication methods via the authServerClient property of the Wallet instance.

Note: The Authentication feature is intended for advanced users who are familiar with deeper integrations and configurations. Ensure you understand its implications before implementing.

Exploring Further

Explore the SDK documentation to learn about the detailed functionalities of each class and method, discover additional features, and understand how to customize the SDK for your needs.

Last updated