Use the MATTR Pi Wallet SDK

Overview

The MATTR Pi Wallet SDK allows you to take advantage of our capabilities to build your own credential apps or add this functionality to other apps where appropriate. The Wallet SDK can utilise MATTR VII and MATTR Pi Wallet APIs to leverage our approach to digital identity and verifiable credentials, but it can also be used with verifiable credentials from other systems.  The use of the SDK will significantly reduce your development time while ensuring you are leveraging safe and reliable code libraries.

Here, we’ll explore some of the capabilities you can expect with MATTR Pi Wallet SDK, and some of the benefits of using this powerful tool. 

Interested in other options for implementing a digital wallet solution? Get in touch with us today.

Benefits

Build using the same tools as the MATTR Wallet 

The MATTR Pi Wallet SDK allows you to take advantage of the core capabilities demonstrated in our MATTR Getting Started Wallet app and use them to build your own mobile wallet experiences without needing to start from scratch. You can also use the toolkit to integrate credential wallet functionalities into other types of applications while maintaining a consistent brand and user experience. This means you can leverage the security, privacy and trust benefits of digital identity and verifiable credentials, while significantly reducing your development time and maintaining a consistent user experience.  

Ongoing support for evolving standards  

MATTR is actively engaged in the communities that define the fast-evolving standards for digital trust and verifiable data. Our investment in updating our SDK to support these standards means that you can rely on our expertise in this space to keep your application relevant and compliant. 

Using the same codebase for iOS and Android 

We’ve built the MATTR Pi Wallet SDK in React Native, which means you can create both iOS and Android apps using the same codebase. React Native is ideally suited to developing complex hybrid apps – given its advanced features and ability to provide a natural user experience. In fact, React Native took the 6th spot in the Stack Overflow Developer Survey 2021, with 14.51% of all respondent votes. 

Limitations 

Our investment roadmap includes ongoing updates and additions to the MATTR Pi Wallet SDK. It is important to note the following limitations at this time: 

  • The SDK is implemented with an initial focus on developers who want to build React Native apps. 

  • The SDK provides a set of operations only, there are no UI elements provided. 

  • At this time, there is no access to a wallet backend to facilitate messaging and push notifications. 

  • Breaking changes to the libraries may occur. We will communicate these with you.

  • Users will be given access to the NPMJS modules that contain obfuscated and minified packages.  

How it works

Create a wallet

Create a new wallet

typescript
Copy to clipboard.
1import { create } from "@mattrglobal/wallet-sdk-react-native"2 
3const createWalletResult = await create(); 
4 
5if (createWalletResult.isErr()) { 
6  // Handle error from createWalletResult.error 
7  return8

Start an OIDC Credential Provider flow 

Discover OIDC credential offer 

typescript
Copy to clipboard.
1const discoverResult = await wallet.oidc.discover("openid://discovery?issuer=https://issuer.example.com"); 
2
3if (discoverResult.isErr()) { 
4  // Handle error from discoverResult.error 
5  return; 
6} 
7
8const { offer } = discoverResult.value; 

Create a local subject DID for the credential 

typescript
Copy to clipboard.
1const createDidResult = await wallet.did.create(); 
2
3if (createDidResult.isErr()) { 
4  // Handle error from createDidResult.error 
5  return; 
6} 
7
8const { did } = createDidResult.value; 

Generate an OpenID authorization url to request the credential 

typescript
Copy to clipboard.
1import { Linking } from "react-native"; 
2const genUrlResult = await wallet.oidc.generateAuthorizeUrl({ offer, did }); 
3
4if (genUrlResult.isErr()) { 
5  // Handle error from genUrlResult.error 
6  return; 
7} 
8
9const { url, codeVerifier, nonce } = genUrlResult.value; 
10await Linking.openURL(url); 

Retrieve the credential on authorization success callback 

typescript
Copy to clipboard.
1const retrieveResult = (retrieveCredential = await wallet.oidc.retrieveCredential({ 
2  offer, 
3  codeVerifier, 
4  nonce, 
5  code: route.params.code, // code comes from part of the callback url 
6})); 
7
8if (retrieveResult.isErr()) { 
9  // Handle error from retrieveResult.error 
10  return; 
11} 
12
13const { credential } = retrieveResult.value; 

Verify a credential 

typescript
Copy to clipboard.
1const verifyResult = await wallet.credential.verify({ credential }); 
2
3if (verifyResult.isErr()) { 
4  // Handle error from verifyResult.error 
5  return; 
6} 
7
8const { credentialVerified, status } = verifyResult.value; 

Respond to a presentation

Open a presentation request DIDComm message 

typescript
Copy to clipboard.
1import { isPresentationRequestJwm } from "wallet-sdk-react-native"; 
2const openResult = await wallet.messaging.openDidCommMessage(message); 
3
4if (openResult.isErr() || !isPresentationRequestJwm(openResult.value)) { 
5  return; 
6} 
7
8const presentationRequest = openResult.value; 

Look up for matching credentials 

typescript
Copy to clipboard.
1const credentialData = [ 
2  { id: "a", credential: credentailA }, 
3  { id: "b", credential: credentailB }, 
4]; 
5
6const filterResult = await wallet.presentation.filterCredentialsByQuery({ credentials: credentialData }); 

Create and send presentation 

typescript
Copy to clipboard.
1const createPresentationResult = await wallet.presentation.create({ 
2  challenge: presentationRequest.body.challenge, 
3  domain: presentationRequest.body.domain, 
4  credentials, 
5  holder: did, 
6}); 
7
8
9if (createPresentationResult.isErr()) { 
10  // Handle error from createPresentationResult.error 
11  return; 
12} 
13
14const presentaiton = createPresentationResult.value; 
15
16const sendPresentationResult = await wallet.presentation.sendPresentationResponse({ 
17  presentationRequest, 
18  presentation, 
19});

Find the comprehensive SDK interfaces for these examples and others in the documentation https://github.com/mattrglobal/docs-wallet-sdk 

Get in touch if you wish to find out more about using the Wallet SDK in production.