Asset or VC Claim
The assetOrVC
claim provides a flexible way to request that a user present either an on-chain asset (like an NFT) or a Verifiable Credential (VC) that meets certain criteria. This is particularly useful for scenarios such as token-gated access where multiple forms of qualification are accepted.
For example, you could grant access to a service if a user either owns a specific membership NFT or holds a valid attendance credential from a past event.
How It Works#
The core of this claim is the filters
array. It allows you to define one or more sets of conditions. The logic is as follows:
- Between Filters (OR): The user only needs to satisfy the conditions of one of the filter objects in the array.
- Within a Filter (AND): The user must meet all the conditions specified within a single filter object.
This structure enables you to create complex and flexible verification requirements.
Parameters#
Each object within the filters
array can contain the following parameters to specify the required criteria. Most parameters are optional, allowing you to tailor the request to your needs.
Parameter | Type | Description |
---|---|---|
|
| An array of acceptable VC types (e.g., |
|
| The DID address of a specific NFT factory or VC. |
|
| An array of DIDs of trusted issuers for the asset or VC. |
|
| An array of DIDs of trusted parent assets (e.g., an NFT collection's DID). Valid only for assets. |
|
| A specific tag that must be present on the asset or VC. |
|
| An array of DIDs, one of which must be the owner of the asset or VC. |
|
| If |
|
| A URL where the user can obtain the required VC if they don't have it. Valid only for VCs. |
|
| A URL where the user can obtain the required asset if they don't have it. Valid only for assets. |
Example: Gated Access with NFT or VC#
Let's create a request for a VIP event. Access is granted to users who either own a 'VIP Pass NFT' from a specific collection or hold a 'VIP Attendee Credential' issued by the event organizer.
const claims = {
assetOrVC: {
description: 'Please present your VIP Pass NFT or VIP Credential to enter.',
filters: [
// Filter 1: User must have the specific NFT
{
trustedParents: ['z82a...gfaV'], // DID of the VIP Pass NFT Collection
consumed: false, // The NFT must not have been used before
acquireUrl: 'https://arcblock.io/nfts/vip-pass-collection',
},
// Filter 2: OR user can have the specific VC
{
type: ['VipAttendeeCredential'],
trustedIssuers: ['z1R...w5vf'], // DID of the Event Organizer
claimUrl: 'https://yourevent.com/claim-vip-credential',
},
],
},
};
// This `claims` object would be passed to the authenticator's sign method.
// const { authInfo } = await authenticator.sign({ claims, ... });
In this example:
- The wallet will first check if the user owns an unconsumed NFT from the collection
z82a...gfaV
. - If not, it will then check if the user holds a
VipAttendeeCredential
issued byz1R...w5vf
. - If either condition is met, the user can proceed. If not, the wallet will show the
acquireUrl
orclaimUrl
as an option.
Wallet Response#
If the user successfully presents a matching asset or VC, the onAuth
callback will receive the presented item in the claims
array. The structure of the response will match the type of item presented (either an asset or a VC).
Here is an example response if the user presented a matching asset:
{
"userDid": "z1...",
"userPk": "...",
"action": "responseAuth",
"challenge": "...",
"claims": [
{
"type": "asset",
"value": {
"address": "z35...pAn",
"owner": "z1...",
"parent": "z82a...gfaV",
"issuer": "z1R...w5vf",
"consumed": false
}
}
]
}
This claim is a versatile tool for creating sophisticated access control and verification logic. To request that the wallet generate a new key pair for the user, proceed to the Key Pair Claim documentation.