# TrustChain reports

For a demo example of following steps, here is the policy timestamp: **1675176247.137536341**

## **Task**

Create a report to check a chain of documents.

## **Preparation**

We will use [example 4](https://guardian.hedera.com/guardian/standard-registry/policies/library-of-policy-examples/mrv-document-operations) to assemble multiple documents to build a realistic-looking *Trustchain*.

Let’s add several additional attributes into the documents to simplify the document search.

![Adding Entity](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f16f273fd2f7a672dd46d5f289308ac73b43bcd7%2F0%20\(3\).png?alt=media)

![Adding Status](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-7477814d048d4648e0419726e59f2c306cae769a%2F1%20\(3\)%20\(1\).png?alt=media)

![Adding Entity](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-fd9a0ca939a2beb4f71187b8c6068f20fcbc8fa9%2F2%20\(4\)%20\(2\).png?alt=media)

![Adding Entity](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-918621fc30a7a1d521c301a00334549752c9495b%2F3%20\(4\)%20\(1\).png?alt=media)

![Adding Type Attribute](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-613ce2b40c37816d0ff93743887e3dea0344a72d%2F4%20\(3\)%20\(2\).png?alt=media)

## **Building the trustchain report:**

1. Using the ‘***reportBlock***’

1.1 Add new container

![Adding new container](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-3f65f1ecfaed5dd21865b6aa6348536ca56f2a79%2F5%20\(1\).png?alt=media)

1.2 Add ‘***reportBlock***’

![Adding reportBlock](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-9e81e157fc344f9a07acdb05ef47caa6d356f7da%2F6%20\(3\).png?alt=media)

In Guardian policy ‘**reportBlock**’ finds VP documents based on their *id* or *hash* and displays document information, related policy and token information. To retrieve the linked information ‘**reportItemBlock**’ must be used.

1.3 We will build the following chain in this example: **mint \_VP – MRV Report – Project (approved and signed the the Approver) – Approver document – Project (created and signed by the user) – User document.**\_

We will need 6 ‘**reportItemBlock**’ items correspondingly, 1 per each document.

![Adding 6 reportItemBlocks](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-9e619fefbd2fbe9eaec3d3e8e2af17d6e6195bff%2F7%20\(3\)%20\(1\).png?alt=media)

The ‘**reportItemBlock**’ items are executed sequentially, thus in the filter for each consecutive ‘**reportItemBlock**’ we can use values from the previous blocks/documents.

1.3.1 ‘**mint\_document**’. To find this document which described the token mint operation we will use one of the **Common Variables** - *actionId*

![Using actionId value](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-d43088063c2f5216c21bc87172d6bad3f0ff36f6%2F8%20\(4\).png?alt=media)

1.3.2 ’**report\_document***’*. To find the MRV report (i.e. data document which was the basis of the decision to mint tokens) we will also use one of the **Common Variables** – *documentId*

![Adding documentId value](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-8c75f2f09f9eb9070ffc5cd8572013b5bb514a94%2F9%20\(3\).png?alt=media)

To find further documents we will need to use values from the **Ref** variable which point to the previous document. Let’s save in a new variable:

![Using Ref variable](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-b58014e60f2b607fc566cebff5f6eaef5b43b979%2F10%20\(3\)%20\(1\)%20\(1\).png?alt=media)

1.3.3 ’**project\_document(approver)***’* - Lets use the previously defined variable alongside the static filtration parameters.

![Using previously defined variables](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f4477bbc8b3ae1e90a4350ea4bd8a27b5b181bf0%2F11%20\(5\)%20\(1\).png?alt=media)

Save the author of the document signature so we can display the information about the user later

![Saving document signature](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-bc77002bab92cf9cfc499ff18a3d8205ce7e343a%2F12%20\(4\).png?alt=media)

**Use the same approach to continue the chain until the end.**

1.3.4 ***’*****approver\_document*****’***

![defining approver\_document block](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-a1122af98d085730d5e61b5d590c72711b4ae51c%2F13%20\(4\).png?alt=media)

1.3.5 ’**project\_document(user)***’*

![defining project\_document(user) block](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-627877a75eb868871f41b10f500a8b7f1d1463fd%2F14%20\(3\).png?alt=media)

1.3.6 ’**user\_document***’*

![defining user\_document block](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-e2645eed230c8fd80ddb2ee05a38f908c8d1e372%2F15%20\(2\).png?alt=media)

2. To activate the ‘**reportBlock**’ an id or a hash of the VP document is needed, we will add the grid containing the list of the VP documents and links to the trustchain.

2.1 Add ‘**interfaceContainerBlock**’, ‘**interfaceDocumentsSourceBlock**’ and ‘**documentsSourceAddon**’

![Adding 3 Blocks](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-c532ae696841d956efd27b48eadd08ebbc345f9c%2F16%20\(2\).png?alt=media)

2.2 Add new column with the type **BUTTON**

![Adding type Button](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-87ae40a7d6dcb22e682624fba1b5392f2bb015a7%2F17%20\(2\).png?alt=media)

Setting the **Action** to LINK will cause the Policy Engine to attempt to switch the display to the target policy block upon the user clicking the link (if possible).

## **Demo**

### VPs:

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-4b0cb93042a55c3d163eaf601a5447509b6bf0a1%2F18%20(2).png?alt=media" alt=""><figcaption></figcaption></figure>

### Trustchain:

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f8ff06ea627e19b4cbc2c02568dc88abef13126a%2F19%20(3).png?alt=media" alt=""><figcaption></figcaption></figure>
