Create Connection

Establish seamless connections between entities.

Create connection is to establish connection between end user and DICE ID issuer.

It involves prompting the user for their email address, setting the email in the invitation input, creating a connection invitation, and receiving the invitation using the wallet ID and token.

API Elements

  1. WALLET_ID: Holds the wallet ID obtained from the 'appconfig' file.

  2. WALLET_TOKEN: Holds the wallet token obtained from the 'appconfig' file.

  3. diceidsdk.issuer.createConnectionInvitation(): Creates a connection invitation using the invitationInput.

  4. invitationInput: An object that holds the credential email for the invitation.

  5. user_email: Stores the email address entered by the user.

  6. resp: Holds the response from the createConnectionInvitation API, including the invitation.

  7. diceidsdk.cloudwallet.receiveInvitation(): Receives the invitation using the wallet ID, wallet token, and the invitation received from createConnectionInvitation.

  8. err: Stores any error that occurs during the process.

Import appconfig: In your JavaScript file, import the 'appconfig' file using the following code:

const { WALLET_ID, WALLET_TOKEN } = require('./appconfig');


function sampleCreateConnection() {
  let connectionOutput = {};
  const invitationInput = {};
  // Prompt the user for their email address
  const user_email = prompt('Enter User Email: ');
  // Set the email in the invitation input
  invitationInput.cred_email = user_email;
  // Create a connection invitation
    .then(resp => {
      // Receive the invitation using the wallet ID and token
      diceidsdk.cloudwallet.receiveInvitation(WALLET_ID, WALLET_TOKEN, resp.invitation);
    .catch(err => console.error("error=" + err));

Running the Code

Step 1: Add the sampleCreateConnection function: Copy the sampleCreateConnection function code and paste it into your JavaScript file after importing the diceidsdk module and the 'appconfig' file..

Step 2: Run the function: Invoke the sampleCreateConnection function in your code to execute it. For example:

node sampleCreateConnection.js 

Step 3: Provide input: The function will prompt you to enter the user's email address. Enter the email address in the terminal or command prompt.

Step 4: Handle the response: Once the receiveInvitation function completes, you can handle the response within the .then() block of the promise or perform any necessary error handling in the .catch() block.

Last updated