# Issue Credential with Encrypted Status List

## Issue Verifiable Credential with Encrypted Bitstring Status List Resource

There is a specific transaction type for issuing Verifiable Credentials that reference encrypted Status List Resources.&#x20;

### Step 1: Create an encrypted Status List on-ledger

Follow the tutorial here to create an encrypted Bitstring Status List Resource on cheqd.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><mark style="color:blue;"><strong>Charge for Status List</strong></mark></td><td>Create an encrypted Status List on cheqd with payment conditions, unlockable on payment of CHEQ</td><td><a href="charge">charge</a></td></tr></tbody></table>

### Step 2: Choose index number for Credential

Each encrypted Status List is a [bitstring](https://en.wikipedia.org/wiki/Bit_array), where each bit represents a Credential which is either revoked or unrevoked (or suspended or unsuspended).

{% hint style="warning" %}
Users should maintain and manage a list of which Credentials match with which specific bitstring indices to be able to revoke or suspend Credentials in the future, and to avoid collisions.
{% endhint %}

When issuing a Credential, you have the choice of whether to manually specify an index for the Credential within the bitstring, or randomly generate an index number anywhere in the bitstring, or within a given range.

### Step 3: Construct Credential Payload with Status List

When constructing the payload for issuing a Credential just specify the purpose and the encrypted status list name.

The following parameters may be included:

| Parameter                | Value       | Optional |
| ------------------------ | ----------- | -------- |
| `"statusPurpose"`        | `"message"` | No       |
| `"statusListName"`       | string      | No       |
| `"statusListVersion"`    | string      | Yes      |
| `"statusListIndex"`      | string      | Yes      |
| `"statusListRangeStart"` | string      | Yes      |
| `"statusListRangeEnd"`   | string      | Yes      |
| `"indexNotIn"`           | Array       | Yes      |

Below are a set of examples of how these parameters may be included in Credential payload files for different purposes:

<details>

<summary>Example Request Format: Random Bitstring Index</summary>

```json
{
    "issuanceOptions": {
        "credential": {
            "credentialSubject": {
                "name": "tweeddalex",
                "id": "did:key:z6MkvG4dpKVpYwYqnwcjRdw8VZ3km4Sisgxm1igaPCFzskxe"
            },
            "issuer": {
                "id": "did:cheqd:testnet:322761ea-587d-454a-a955-745200301b99"
            },
            "type": [
                "VerifiableCredential", "Profile"
            ],
            "@context": [
                "https://www.w3.org/2018/credentials/v1",
                "https://veramo.io/contexts/profile/v1"
            ]
        },
        "proofFormat": "jwt"
    },
    "statusOptions": {
        "statusPurpose": "message",
        "statusListName": "status-list-encrypted"
    }
}

```

</details>

<details>

<summary>Example Request Format: Bitstring index within a given range</summary>

```json
{
    "issuanceOptions": {
        "credential": {
            "credentialSubject": {
                "name": "tweeddalex",
                "id": "did:key:z6MkvG4dpKVpYwYqnwcjRdw8VZ3km4Sisgxm1igaPCFzskxe"
            },
            "issuer": {
                "id": "did:cheqd:testnet:322761ea-587d-454a-a955-745200301b99"
            },
            "type": [
                "VerifiableCredential"
            ],
            "@context": [
                "https://www.w3.org/2018/credentials/v1",
                "https://veramo.io/contexts/profile/v1"
            ]
        }
    },
    "statusOptions": {
        "statusPurpose": "message",
        "statusListName": "status-list-encrypted",
        "statusListIndex": 1456
    }
}

```

</details>

<details>

<summary>Example Request Format: Bitstring including omitted bits</summary>

```json
{
    "issuanceOptions": {
        "credential": {
            "credentialSubject": {
                "name": "tweeddalex",
                "id": "did:key:z6MkvG4dpKVpYwYqnwcjRdw8VZ3km4Sisgxm1igaPCFzskxe"
            },
            "issuer": {
                "id": "did:cheqd:testnet:322761ea-587d-454a-a955-745200301b99"
            },
            "type": [
                "VerifiableCredential"
            ],
            "@context": [
                "https://www.w3.org/2018/credentials/v1",
                "https://veramo.io/contexts/profile/v1"
            ]
        }
    },
    "statusOptions": {
        "statusPurpose": "message",
        "statusListName": "status-list-encrypted",
        "statusListRangeStart": 2000,
        "statusListRangeEnd": 3000
    }
}

```

</details>

<details>

<summary>Example Request Format: Specified Bitstring index</summary>

```json
{
    "issuanceOptions": {
        "credential": {
            "credentialSubject": {
                "name": "tweeddalex",
                "id": "did:key:z6MkvG4dpKVpYwYqnwcjRdw8VZ3km4Sisgxm1igaPCFzskxe"
            },
            "issuer": {
                "id": "did:cheqd:testnet:322761ea-587d-454a-a955-745200301b99"
            },
            "type": [
                "VerifiableCredential"
            ],
            "@context": [
                "https://www.w3.org/2018/credentials/v1",
                "https://veramo.io/contexts/profile/v1"
            ]
        }
    },
    "statusOptions": {
        "statusPurpose": "message",
        "statusListName": "status-list-encrypted",
        "statusListRangeStart": 10,
        "statusListRangeEnd": 3000,
        "indexNotIn": 13, 1807, 2434
    }
}

```

</details>

{% hint style="info" %}
Ensure that the `"statusPurpose"`  is `message` and `"statusListName"` is the same as the existing Status List on-ledger, [created in Step 1](#step-1-create-an-encrypted-status-list-on-ledger).&#x20;
{% endhint %}

### Step 4: Execute the transaction

Once you have constructed your payload file, and have saved it as a JSON file, use the transaction below to issue the Verifiable Credential.

```
veramo execute -m cheqdIssueCredentialWithStatusList --argsFile path/to/payload.json
```

#### Response format

If the transaction is successful, you will get returned a formatted Verifiable Credential, including a populated `"credentialStatus"` section.&#x20;

<details>

<summary>Example Response Format</summary>

```json
Result : {
  "credentialSubject": {
    "name": "tweeddalex",
    "id": "did:key:z6MkvG4dpKVpYwYqnwcjRdw8VZ3km4Sisgxm1igaPCFzskxe"
  },
  "issuer": {
    "id": "did:cheqd:testnet:cc8e5d9f-05f8-4f09-93c5-b9dba4b45404"
  },
  "type": [
    "VerifiableCredential",
     "Profile"
  ],
  "credentialStatus": {
    "id": "https://resolver.cheqd.net/1.0/identifiers/did:cheqd:testnet:322761ea-587d-454a-a955-745200301b99?resourceName=status-list-encrypted&resourceType=BitstringStatusListCredential#1211",
    "type": "BitstringStatusListEntry",
    "statusPurpose": "message",
    "statusListIndex": "1211",
    "statusListCredential": "https://resolver.cheqd.net/1.0/identifiers/did:cheqd:testnet:322761ea-587d-454a-a955-745200301b99?resourceName=status-list-encrypted&resourceType=BitstringStatusListCredential",
    "statusSize": 2,
    "statusMessage": [
      {
        "status": "0x0",
        "message": "valid"
      },
      {
        "status": "0x1",
        "message": "revoked"
      },
      {
        "status": "0x2",
        "message": "suspended"
      },
      {
        "status": "0x3",
        "message": "unknown"
      }
    ]
  },
  "@context": [
    "https://www.w3.org/2018/credentials/v1",
    "https://veramo.io/contexts/profile/v1",
    "https://w3id.org/vc-status-list-2021/v1"
  ],
  "issuanceDate": "2023-08-18T01:39:53.000Z",
  "proof": {
    "type": "JwtProof2020",
    "jwt": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vdmVyYW1vLmlvL2NvbnRleHRzL3Byb2ZpbGUvdjEiLCJodHRwczovL3czaWQub3JnL3ZjLXN0YXR1cy1saXN0LTIwMjEvdjEiXSwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJuYW1lIjoidHdlZWRkYWxleCJ9LCJjcmVkZW50aWFsU3RhdHVzIjp7ImlkIjoiaHR0cHM6Ly9yZXNvbHZlci5jaGVxZC5uZXQvMS4wL2lkZW50aWZpZXJzL2RpZDpjaGVxZDp0ZXN0bmV0OmNjOGU1ZDlmLTA1ZjgtNGYwOS05M2M1LWI5ZGJhNGI0NTQwND9yZXNvdXJjZU5hbWU9dGVzdGluZy1wYXltZW50LXJhaWxzJnJlc291cmNlVHlwZT1TdGF0dXNMaXN0MjAyMVJldm9jYXRpb24jMTIzOTc5IiwidHlwZSI6IlN0YXR1c0xpc3QyMDIxRW50cnkiLCJzdGF0dXNQdXJwb3NlIjoicmV2b2NhdGlvbiIsInN0YXR1c0xpc3RJbmRleCI6IjEyMzk3OSJ9fSwic3ViIjoiZGlkOmtleTp6Nk1rdkc0ZHBLVnBZd1lxbndjalJkdzhWWjNrbTRTaXNneG0xaWdhUENGenNreGUiLCJuYmYiOjE2OTIzMjI3OTMsImlzcyI6ImRpZDpjaGVxZDp0ZXN0bmV0OmNjOGU1ZDlmLTA1ZjgtNGYwOS05M2M1LWI5ZGJhNGI0NTQwNCJ9.RPt5D021S0MzUscptUc0CZtK9a2sEvGYOkJkx0EO8xqQwTIQRfL7-Z-ZTbOo2OiHs-kDrXQ8SbTMf2yk1QR_Ag"
  }
}
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cheqd.io/product/sdk/veramo/payments/issue-paid-credential.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
