Skip to content

This repository contains demo code that shows how to issue an achievement credential using a simple snake game as example.

Notifications You must be signed in to change notification settings

animo/paradym-example-achievement-credential

Repository files navigation


screenshot-snake screenshot-qr

Issue an achievement credential with Paradym

Easily integrate Paradym workflows into your existing application with this demo. This demo shows how Paradym can be used to issue an achievement credential using a simple snake game example.

This demo contains two packages: client and server. Both of these are located in the /packages directory. In order to get this demo to work, you will need to create two workflows and configure the environment variables in the .env.example file located /packages/server directory. To do so, follow the instructions below.

Before you begin

Check out the YouTube video for a complete walkthrough of the demo application and its workflows.

This demo uses Paradym, a workflow builder for developers that provides the actions, workflows and infrastructure you need to use verifiable credentials in your solution.

If you don't have an account yet, you can start with our quick start guide.

This demo also uses the Paradym Wallet, an open source companion app to the Paradym platform available on the Apple App Store and Google Play Store.

Prerequisites

Setup your workflows

The demo app requires 2 workflows. All workflows used for this demo application can be found in the /paradym folder.

  • Register Credential Template: workflow used to register your credential schema and definition. The result of this workflow is used in the issuance workflow.
  • Issue High Score Badge: workflow used to issue the achievement credential once the player beats the high score.

Step 1: Register your credential information

  • Create a new workflow in Paradym with the name Register Credential Template.
  • Copy the contents from registerCredentialTemplate.yaml into your created workflow.
  • Publish the workflow.
  • Execute the workflow via the executions tab.
  • Click on the execution to view the result of your workflow.
  • Copy the credentialDefinitionId from the result and save the value for later.

Step 2: Create the issue high score badge workflow

Next, you need to create the Issue High Score Badge workflow.

  • Create new workflow in the Paradym dashboard
  • Copy the contents of the paradym/issueHighScoreBadge.yaml file
  • Replace the content of the newly created workflow with the value you just copied.
  • Replace the <YOUR_CREDENTIAL_DEFINITION_ID> values with the credentialDefinitionId value from step 1.
  • Publish the workflow.

Once you have created the workflow in the Paradym dashboard, you can copy the workflow ID from Paradym and set it as the value for the PARADYM_WORKFLOW_ID environment variable in packages/server/.env.example.

Step 3: Create your Paradym API Key

You can generate your API key in the settings tab on the Paradym dashboard as described in here. Copy the API key and set it as the value for the PARADYM_API_KEY environment variable in packages/server/.env.example.

Step 4: Setup Paradym Webhook

The application uses Paradym Webhooks. For this, we need to create a Webhook in the Paradym dashboard (as described here).

For this to work with your local environment, we'll need to expose port 3000 to the internet. This can be done using ngrok. Once you have installed ngrok, you can run the following command to expose port 3000 to the internet.

ngrok http 3000

Use the https url to create your webhook in the Paradym dashboard. Make sure to add /webhook after the url (e.g. https://107a-217-123-79-23.ngrok-free.app/webhook).

After creating the webhook endpoint, copy the webhook secret and set it as the value for the PARADYM_HMAC_SIGNATURE in packages/server/.env.example.

NOTE: Keep the ngrok server running and use a different terminal window for the following steps. If you restart the ngrok process, the URL will change and you have to reconfigure the webhook URL in paradym.

Step 5: Set the environment variables

The environment variables consist of your Paradym API Key, and the ID's of the workflows just created. Once you have created the workflows in the Paradym dashboard, you can copy the workflow ID's from Paradym and set them as environment variables.

cp packages/server/.env.example packages/server/.env
Variable Description
PARADYM_API_KEY This is the API key used to send request to Paradym. You can generate your API key in the settings tab on the Paradym dashboard as described in here.
PARADYM_WEBHOOK_SECRET This is a secret that is generated once you create a Webhook in the Paradym dashboard. You can set up a Webhook in the settings tab on the Paradym dashboard as described in here.
PARADYM_WORKFLOW_ID This is the ID of the issue achievement credential workflow. Once you have created the workflow in Paradym you can copy the ID from the executions tab.

Running the demo

Now you have created the workflows and configured the environment variables, the last thing you need to do before you can run the demo is install the dependencies for both the client and server packages.

cd packages/server
yarn
cd ../client
yarn
cd ../..

Now you need to start the development servers for both packages. Don't forget that

In your current terminal, run

cd packages/server
yarn dev

Open up a second terminal window, and run

cd packages/client
yarn dev

The last command will print a URL to the console. Copy and paste this URL into your browser to open up the snake game.

About

This repository contains demo code that shows how to issue an achievement credential using a simple snake game as example.

Resources

Stars

Watchers

Forks

Releases

No releases published