DICE Developer Docs
  • Developer Docs
    • DICE Test Drive
      • Sign-up for Issuer Portal
      • Issue Credentials
      • Verify Credentials
    • Key Concepts
      • DID & Verifiable Credentials
      • DICE ID Architecture
    • Platform Console
      • Dashboard
      • Customers
        • Onboard Customer
      • Credentials
        • Issue Credentials to New Customer
      • Schema
      • Batch Issuance
        • Batch Issuance - Useful Tips
      • Verifications
        • Verification Template
      • Templates
        • Certificate Template
          • Create Template
          • Manage Template
        • Email Template
          • Create Template
          • Manage Template
      • Organization
      • Departments
      • Organization Users
      • API Access
      • Callback Configuration
      • Tutorials
        • Credential Issuance from DICE ID Console
        • Credential Issuance using DICE ID APIs
        • Credential Verification using QR code
        • Credential Verification from DICE ID console
        • Batch Credential Issuance from DICE ID Console
    • Integrations
      • Auth0 Integration
        • Login using OIDC (First Factor Authentication)
        • Custom MFA Rule (For 2FA)
    • DICE ID SDK
      • DICE ID
        • DID & Verifiable Credentials
        • DICE ID Architecture
      • SDK Functionalities
      • Create Wallet
      • Create Connection
      • Creating a Schema
      • Issue a Credential
      • Send Presentation Request
      • Get Verification State
      • Configuration and Customization
      • Error Handling & Troubleshooting
      • Conclusion
      • Additional Resources
  • Getting Started with DICE ID Skill Credentials
    • Building Trust Ecosystems Powered by Credentials
    • DICE ID Integration for Issuers
    • DICE ID Integration for Verifiers
    • DICE ID Brand Usage Guidelines
    • DICE ID Onboarding Confirmation
    • Helpful Q&A
    • Troubleshooting Guide
Powered by GitBook
On this page
  1. Developer Docs
  2. DICE ID SDK

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');

sampleCreateConnection()

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
  diceidsdk.issuer.createConnectionInvitation(invitationInput)
    .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.

PreviousCreate WalletNextCreating a Schema

Last updated 1 year ago