# Dapp queries overview · Build with zero-knowledge proofs on Chromia · Learn Chromia

> This guide walks through the queries in the zkp-demo workspace. The workspace shows how to build a private token transfer system on Chromia with…

Source: https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-queries/

Build with zero-knowledge proofs on ChromiaLesson 15 of 19

1. [01Introduction to the course](https://chromia.com/learn/zero-knowledge-proof/introduction/)
2. [02Zero-knowledge proof](https://chromia.com/learn/zero-knowledge-proof/zero-knowledge-proof/)
3. [03Project setup](https://chromia.com/learn/zero-knowledge-proof/setup/)
4. [04Architecture overview](https://chromia.com/learn/zero-knowledge-proof/architecture-overview/)

Module 1: Writing Circom circuits

1. [05Overview](https://chromia.com/learn/zero-knowledge-proof/circom-circuits/)
2. [06Circom circuits: introduction](https://chromia.com/learn/zero-knowledge-proof/circom-circuits/circom-circuits-introduction/)
3. [07Circom files overview](https://chromia.com/learn/zero-knowledge-proof/circom-circuits/circom-circuits-project/)
4. [08Circom circuits: compile](https://chromia.com/learn/zero-knowledge-proof/circom-circuits/circom-circuits-compile/)

Module 2 – Dapp

1. [09Overview](https://chromia.com/learn/zero-knowledge-proof/dapp/)
2. [10Dapp: setup and run](https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-setup-run/)
3. [11Dapp overview](https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-overview/)
4. [12Dapp entities](https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-entities/)
5. [13PLONK verification](https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-verification/)
6. [14Dapp operations overview](https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-operations/)
7. [15Dapp queries overview](https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-queries/)

Module 3 – Frontend

1. [16Overview](https://chromia.com/learn/zero-knowledge-proof/frontend/)
2. [17Frontend: setup and run](https://chromia.com/learn/zero-knowledge-proof/frontend/frontend-setup-run/)
3. [18Frontend architecture](https://chromia.com/learn/zero-knowledge-proof/frontend/frontend-explore/)
4. [19Frontend: test](https://chromia.com/learn/zero-knowledge-proof/frontend/frontend-test/)

[Learn](https://chromia.com/learn/)[Build with zero-knowledge proofs on Chromia](https://chromia.com/learn/zero-knowledge-proof/)

15 / 19Module 2 – DappAdvanced

# Dapp queries overview

This guide walks through the queries in the zkp-demo workspace. The workspace shows how to build a **private token transfer system** on Chromia with zero-knowledge proofs.

## Queries

The queries fall into the following groups:

### Transaction queries

rell/src/zkp\_demo/operations.rell

```
// Check nullifier status
query is_nullifier_spent(nullifier_hash: big_integer) {
    return spent_nullifier @? { .nullifier_hash == nullifier_hash } != null;
}

// Get unspent commitments
query get_all_unspent_commitments() {
    return unspent_commitment @* {} (.commitment_hash);
}

// Get transfer events
query get_private_transfer_events() {
    return private_transfer_event @* {} ($.to_struct());
}

// Get test asset
query get_test_asset() {
    return init.test_asset.to_struct();
}
```

### Shield/unshield queries

rell/src/zkp\_demo/operations.rell

```
// Get shield logs
query get_shield_logs(): list<struct<shield_log>> {
    return shield_log @* {} ($.to_struct());
}

// Get unspent shield logs by account
query get_all_unspent_shield_logs_by_account_id(account_id: byte_array): list<struct<shield_log>> {
    return (uc: zkp_demo.unspent_commitment, sl: shield_log) @* { 
        uc.commitment_hash == sl.commitment, 
        sl.account_id == account_id 
    } (sl.to_struct());
}

// Get unshield logs
query get_unshield_logs(): list<struct<unshield_log>> {
    return unshield_log @* {} ($.to_struct());
}
```

### Address registry queries

rell/src/zkp\_demo/operations.rell

```
// Get private address by account ID
query get_private_address_by_account_id(account_id: byte_array): big_integer? {
    return private_address_registry @? { account_id } ( .private_address );
}

// Get encryption key by account ID
query get_public_encryption_key_by_account_id(account_id: byte_array): text? {
    return private_address_registry @? { account_id } ( .public_encryption_key );
}

// Get both private address and public encryption key by account ID
query get_user_keys_by_account_id(account_id: byte_array): (private_address: big_integer?, public_encryption_key: text?) {
    val user = private_address_registry @? { account_id };
    return (
        private_address = user?.private_address,
        public_encryption_key = user?.public_encryption_key
    );
}

// Get all registered users
query get_all_registered_users() {
    return private_address_registry @* {} ( $.to_struct() );
}

// Get EVM wallet address from account ID
query get_user_wallet_address(account_id: byte_array): byte_array? {
    val account = ft4.accounts.account @? { .id == account_id };
    if (account == null) return null;
    
    var evm_wallet_address: byte_array? = null;

    val auth_descriptor_signers = (
        mad: ft4.accounts.main_auth_descriptor,
        ads: ft4.accounts.auth_descriptor_signer
    ) @* {
        account == mad.account,
        ads.account_auth_descriptor == mad.auth_descriptor
    } ( ads );

    for (auth_descriptor_signer in auth_descriptor_signers) {
        if (auth_descriptor_signer.id.size() == 20) {
            evm_wallet_address = auth_descriptor_signer.id;
            break;
        }
    }

    return evm_wallet_address;
}
```

## Integration with FT4

The ZKP demo builds on Chromia's FT4 framework in three areas:

* **Account authentication**: relies on the authentication system that FT4 provides
* **Asset management**: handles public tokens through FT4's asset functionality
* **Balance operations**: works with FT4's balance management

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Dapp operations overview**](https://chromia.com/learn/zero-knowledge-proof/dapp/dapp-operations/)[Next →**Module 3 – Frontend**](https://chromia.com/learn/zero-knowledge-proof/frontend/)

On this page

* [Queries](#queries)
* [Integration with FT4](#integration-with-ft4)
