Skip to main content

Present a Credential

To present credentials to other wallets, follow these steps:

  1. Create a new presentation.
  2. Configure the presentation with credentials and necessary settings.
  3. Issue the created presentation.
  4. Send the issued presentation to a target wallet.

Create Presentation

Start by creating a new empty presentation. Use the following code to do so:

PRESENTATION=$(curl --request POST \
--url "https://api.truvity.com/api/wallet/v1/vp?entityDid=${ENTITY_DID}&walletDid=${WALLET_DID}" \
--header 'Content-Type: application/json' \
--header "X-API-KEY: ${TRUVITY_API_KEY}"

PRESENTATION_DID=$(echo $PRESENTATION | jq -r '.VpDid')
PRESENTATION_REVISION=$(echo $PRESENTATION | jq -r '.Revision')

Add Credentials

After creating a new presentation, configure it with credentials and necessary settings.

tip

At the moment, we only support basic configuration without support for partial disclosure or terms of use.

Please join our Discord server to get updates about future developments.

Use the following code to update the presentation:

# updates PRESENTATION_REVISION with latest revision number
PRESENTATION_REVISION=$(curl --request POST \
--url "https://api.truvity.com/api/wallet/v1/vp/from-vc/${PRESENTATION_DID}?revision=${PRESENTATION_REVISION}&entityDid=${ENTITY_DID}&walletDid=${WALLET_DID}" \
--header 'Content-Type: application/json' \
--header "X-API-KEY: ${TRUVITY_API_KEY}" \
--data "{\"CredentialDid\": \"${CREDENTIAL_DID}\"}" | jq -r '.Revision')

Issue Presentation

Once we have finished configuring, we need to issue the created presentation to make it a verifiable presentation. Use the following code to do so:

# updates PRESENTATION_REVISION with latest revision number
PRESENTATION_REVISION=$(curl --request POST \
--url "https://api.truvity.com/api/wallet/v1/vp/${PRESENTATION_DID}?revision=${PRESENTATION_REVISION}&entityDid=${ENTITY_DID}&walletDid=${WALLET_DID}" \
--header "X-API-KEY: ${TRUVITY_API_KEY}" | jq -r '.Revision')

Send Presentation

After issuing a VP, we can send it to a target wallet using a DIDComm message. Use the following code to do so:

tip

You can repeate the steps of Create a Wallet to create a new Entity and Wallet and use their DIDs to set as TARGET_ENTITY_DID and TARGET_WALLET_DID here.

curl --request POST \
--url "https://api.truvity.com/api/wallet/v1/didcomm/send-plaintext?entityDid=${ENTITY_DID}&walletDid=${WALLET_DID}" \
--header 'Content-Type: application/json' \
--header "X-API-KEY: ${TRUVITY_API_KEY}" \
--data "{\"Target\": {\"EntityDid\": \"${TARGET_ENTITY_DID}\", \"WalletDid\": \"${TARGET_WALLET_DID}\"}, \"VpDid\": \"${PRESENTATION_DID}\"}"
tip

At the moment, we only support direct DIDComm routing by wallet DID.

Please join our Discord server to get updates about future developments.

Further reading