> ## Documentation Index
> Fetch the complete documentation index at: https://docs.digitalasset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Blocklist

> Learn how to block parties through the dApp UI and the DA Registry API.

> [!NOTE]
>
> This feature was introduced with version `0.13.1` of the Registry App; version `0.7.1` of the utility-registry-v0 (the block list check field), extended with sharding and UI support in version `0.14.0` of the Registry App; version `0.8.0` of utility-registry-v0.
>
> An instrument for which the blocklist check is enabled is not compatible with Daml models introduced in previous releases.

## Overview

A blocklist is managed at the instrument admin (i.e. registrar) level, and applies to all instruments managed by that party for which the blocklist check is enabled. Once enabled on an instrument, every sender and receiver (or holder, for burns) involved in a transfer, mint, burn, or allocation of that instrument — across both Token Standard V1 and V2 flows — must not appear in the registrar's blocklist, or the transaction is rejected.

On-ledger, the blocklist is a set of `StoredBlockListPartyShas` contracts ("shards"), signed by the registrar and observed by the operator, that store the SHA-256 hashes of blocklisted parties, sharded by hash prefix (see [Cost considerations](#cost-considerations)).

```mermaid theme={null}
flowchart LR
  subgraph Registrar["Registrar-owned contracts"]
    IC["InstrumentConfiguration\ncheckBlockList = Some True"]
    S0["StoredBlockListPartyShas\nprefix: 0"]
    S1["StoredBlockListPartyShas\nprefix: 1"]
    Sf["StoredBlockListPartyShas\nprefix: f"]
    S0 -.splits when full.-> S00["prefix: 00"]
    S0 -.splits when full.-> S0f["prefix: 0f"]
  end
  IC -- "checked against" --> S0
  IC -- "checked against" --> S1
  IC -- "checked against" --> Sf
```

The steps below can be performed either from the Registry dApp UI, or directly against the ledger/JSON API by exercising the underlying choices — both paths are equivalent.

> [!TIP]
>
> You can jump straight to a step: [1. Instantiate](#1-instantiate-the-blocklist) · [2. Enable on an instrument](#2-enable-blocklist-verification-on-an-instrument) · [3. Add parties](#3-add-parties-to-the-blocklist) · [4. Remove parties](#4-remove-parties-from-the-blocklist) · [5. View](#5-view-the-current-blocklist).

## Step-by-step setup guide

**1. Instantiate the blocklist**

When a registrar onboards (accepts a `RegistrarServiceRequest`) from version `0.14.0` of the Registry App onwards, 16 shards are created automatically for it, one for each hexadecimal prefix character (`0`-`f`), each with a maximum shard size of 16 entries — no further action is needed.

Registrars onboarded before this feature was available (or whose shards are otherwise missing) must instantiate the blocklist once before it can be used.

> [tab] dApp UI
>
> Navigate to **Blocklist** in the left navigation sidebar and click **Create blocklist**. The button is disabled once shards already exist, so it is safe to attempt this step even if you are unsure whether the blocklist was already created.

> [tab] API
>
> Exercise `RegistrarService_CreateBlockListShards` on your `RegistrarService` contract, with `maxBlockListShardSize` set to the desired shard size (`16` is the value used by the UI).

> [!WARNING]
>
> Do this before enabling blocklist verification on any instrument — otherwise all transfers, mints, burns, and allocations for that instrument will fail, since no `StoredBlockListPartyShas` shard will be resolvable for the disclosed choice context.

**2. Enable blocklist verification on an instrument**

Blocklist verification is configured per instrument, via the `checkBlockList` field of the instrument's `InstrumentConfiguration` contract.

> [tab] dApp UI
>
> Tick **Use block list** when creating the instrument from **Configuration**, or open an existing instrument and enable it via the modify dialog.

> [tab] API
>
> Set `useBlockList` to `Some True` when exercising `RegistrarService_CreateInstrumentConfiguration` (new instrument), or exercise `RegistrarService_ArchiveAndCreateInstrumentConfiguration` with `useBlockList = Some True` (existing instrument).

> [!NOTE]
>
> Enabling the blocklist check on an instrument makes it incompatible with Daml models introduced before release `0.13` (the `checkBlockList` field cannot be dropped when downgrading to a package version that predates it).

**3. Add parties to the blocklist**

> [tab] dApp UI
>
> From the **Blocklist** page, click **Add party to blocklist**, enter the party id(s), and confirm.

> [tab] API
>
> 1. Compute the SHA-256 hash of the party's textual id (`sha256(partyToText(party))`).
> 2. Query for the registrar's `StoredBlockListPartyShas` contracts and find the one whose `prefix` matches the start of that hash.
> 3. Exercise `StoredBlockListPartyShas_AddSha` on that shard, with `p` set to the party to blocklist.
>
> If adding the entry would exceed the shard's `maxBlockListShardSize`, the choice automatically and recursively splits the shard into up to 16 child shards with a longer prefix — the result contains the updated set of `(prefix, contractId)` shards, which you should use for any subsequent lookups.

Once added, the party is blocked for every instrument of that registrar with blocklist verification enabled.

**4. Remove parties from the blocklist**

> [tab] dApp UI
>
> From the **Blocklist** page, locate the party in the table and click **Remove**, then confirm.

> [tab] API
>
> Locate the shard containing the party's hash (as in step 3) and exercise `StoredBlockListPartyShas_RemoveSha` with `p` set to the party to remove.

**5. View the current blocklist**

> [tab] dApp UI
>
> The **Blocklist** page lists all currently blocked parties. A "view raw" option is also available for inspecting the underlying `StoredBlockListPartyShas` shards and their stored SHA-256 hashes directly, rather than the resolved party list.

> [tab] API
>
> Query the registrar's `StoredBlockListPartyShas` contracts (e.g. via `StoredBlockListPartyShas_PublicFetch` for parties without direct visibility) and inspect their `blockList` fields.

## How the check runs at transaction time

When blocklist verification is enabled on an instrument, every transfer, mint, burn, or allocation resolves and discloses only the relevant shard(s) via the choice context, then checks the sender/receiver against them:

```mermaid theme={null}
sequenceDiagram
  participant Client as Registry dApp / API client
  participant Registry as Registry App (backend)
  participant Rule as TransferRule / AllocationFactory
  participant Shard as StoredBlockListPartyShas (matching prefix)

  Client->>Registry: Request transfer / mint / burn / allocation factory
  Registry->>Shard: Resolve shard(s) for sender & receiver hash prefixes
  Registry-->>Client: ChoiceContext (includes disclosed shard contracts)
  Client->>Rule: Exercise choice with ChoiceContext
  Rule->>Shard: Check sender/receiver SHA-256 not in blockList
  alt party blocklisted
    Rule-->>Client: Transaction rejected
  else party not blocklisted
    Rule-->>Client: Transaction succeeds
  end
```

## Cost considerations

Using the blocklist feature requires additional contracts to be disclosed as part of the `ChoiceContext` for transfer, minting, burning, and allocation transactions.

The blocklist is sharded across different party prefixes, so that the cost of these transactions is bounded, rather than linearly increasing with the number of parties in the blocklist. Concretely:

* Parties are identified in the blocklist by the SHA-256 hash of their party id, not the raw party id.
* The blocklist starts as 16 shards, one per single hex-character prefix of that hash.
* Each shard independently splits into 16 children (extending its prefix by one more hex character) once it would exceed its configured `maxBlockListShardSize`, so shard sizes stay bounded regardless of how many parties are blocklisted overall.
* At transaction time, only the shard(s) whose prefixes match the sender's and receiver's (or holder's) party hash need to be resolved and disclosed via the choice context — not the entire blocklist — keeping the disclosure size, and therefore the transaction cost, roughly constant as the blocklist grows.

## For Trading Venues

### Check Whether an Instrument Has the Blocklist Check Set

Settlements of instruments with `checkBlockList` set require all involved participants to have
vetted Registry App version `0.13` or later, see the
[trading venue guidelines](https://docs.digitalasset.com/registry/apis/token-standard/cross-version-compatibility.md#trading-venue-guidelines).
To check the setting of an instrument, call the instrument configuration endpoint of the Registry
App with the instrument's default identifier:

```
POST /api/utilities/v0/contract/instrument-configuration
```

```json theme={null}
{
  "registrar": "<instrument admin party ID>",
  "instrumentIdentifier": {
    "source": "<instrument admin party ID>",
    "id": "<instrument ID>",
    "scheme": "RegistrarInternalScheme"
  }
}
```

The `payload.checkBlockList` field of the response shows the blocklist setting of the instrument:

* `true`: the blocklist check is enabled.
* `false`: the blocklist check is disabled.
* `null` or missing: the blocklist check is disabled, and the setting is unset.

Both `true` and `false` require Registry App version `0.13` or later for settlements. Only `null` allows a settlement on an earlier version.

> [!NOTE]
>
> The endpoint returns the `checkBlockList` field from release `0.15` onwards
> ([Operator Backend API](https://docs.digitalasset.com/registry/apis/operator-backend-api.md) `2.2.0`).
