Getting Started
This guide walks you through the process of setting up the Dock Wallet SDK, creating a wallet, managing decentralized identifiers (DIDs), adding credentials, and verifying them.
Installation
To start, you need to install the necessary packages for the wallet SDK and the data store. Open your terminal and run the following command:
The @docknetwork/wallet-sdk-core
provides the core wallet functionality, while @docknetwork/wallet-sdk-data-store-typeorm
handles data persistence using a local SQLite database.
Usage Example
1. Initialize the Data Store
Before creating a wallet, you need to set up a data store to manage the persistence of wallet data such as DIDs and credentials. Here’s how to create a data store:
This code initializes a SQLite database to store wallet data. You can adjust the databasePath
and defaultNetwork
based on your needs.
If you want to use the cloud wallet solution, please refer to the Cloud Wallet Documentation for detailed instructions and configuration options.
2. Create a New Wallet
Once the data store is set up, you can create a wallet. The wallet will act as a container for managing your documents, DIDs, and credentials.
This creates a new wallet instance that links to the previously created data store.
3. Fetch your DIDs
DIDs (Decentralized Identifiers) are a key part of self-sovereign identity. When a wallet is created, a default DID is automatically generated. You can retrieve and view the default DID associated with your wallet using the following code:
4. Add a Credential to the Wallet
Once you have a wallet and a DID, you can start managing credentials. In this example, you will import a credential from a URL into the wallet.
In this example, the credential is fetched from a specified URI and imported into the wallet. The getAuthCode
function is used to handle any authentication, such as providing a password if required.
5. Verify a Credential
The Dock Wallet SDK provides built-in functionality for verifying credentials. This is especially useful when interacting with third parties who need to verify your credentials. The verification controller manages this process. Below is an example of how to start a verification, select which credentials to reveal, create a presentation, and submit it for verification.
In this example, the verification process starts by fetching a proof request template. After selecting the credentials and specifying which attributes to reveal, the wallet creates a verifiable presentation. The presentation is then submitted, and the verifier responds with a verification result.
Last updated