# How to run queries · Chromia Docs (concept)

> Queries are read-only operations that retrieve data from your blockchain without modifying state.

Source: https://docs.chromia.com/build/cookbook/cli/run-queries/

# How to run queries

On this page

* [Prerequisites](#prerequisites)
* [Basic query workflow](#basic-query-workflow)
* [Step 1: Verify your node is running](#step-1-verify-your-node-is-running)
* [Step 2: Run a simple query](#step-2-run-a-simple-query)
* [Query methods overview](#query-methods-overview)
* [Local queries (development)](#local-queries-development)
* [Remote queries (deployed dapps)](#remote-queries-deployed-dapps)
* [Query parameters](#query-parameters)
* [Basic parameter types](#basic-parameter-types)
* [Advanced parameter types](#advanced-parameter-types)
* [Testing against deployed dapps](#testing-against-deployed-dapps)
* [Testnet queries](#testnet-queries)
* [Next steps](#next-steps)

Queries are read-only operations that retrieve data from your blockchain without modifying state. This guide shows you
how to use queries during development and testing.

## Prerequisites

* [Chromia CLI installed](https://docs.chromia.com/get-started/installation/)
* [Rell dapp project created](https://docs.chromia.com/build/cookbook/cli/create-rell-dapp/) with local node running OR access to a deployed dapp

## Basic query workflow

### Step 1: Verify your node is running

Terminal

```
# Check if local node is responding
curl http://localhost:7740
```

### Step 2: Run a simple query

Terminal

```
# Test the default hello_world query (--local is the default)
chr query hello_world
```

Expected output:

Plain text

```
"Hello World!"
```

**Note**: You can also use the Blockchain RID explicitly:

Terminal

```
chr query --blockchain-rid <BlockchainRID> hello_world
```

Replace `<BlockchainRID>` with the actual Blockchain RID from your node output. You can find this in the node startup
output as: `Blockchain RID: FC17B67D66F6F35A5D8B75ED3F83AE222FB8C8FCA241624F06285150F10C6BAC`

## Query methods overview

### Local queries (development)

Terminal

```
# Default local query
chr query hello_world

# Explicit blockchain RID (equivalent to --local for development)
chr query --blockchain-rid <BlockchainRID> hello_world
```

### Remote queries (deployed dapps)

Terminal

```
# Query deployed dapp using network and blockchain name
chr query --network testnet --blockchain my_rell_dapp hello_world
```

## Query parameters

When you create queries that accept parameters, use this syntax based on the
[official CLI documentation](https://docs.chromia.com/build/cli/commands/query/):

### Basic parameter types

Terminal

```
# String parameters (quoting optional for simple strings)
chr query my_query arg1=Alice arg2=hello

# Strings with spaces (require quotes)
chr query my_query 'arg1="My Neighbor"' arg2=hello

# Integer parameters
chr query my_query arg1=123 arg2=456

# Multiple parameters example from official docs
chr query hello_world foo=17 bar=hello 'baz="hello world"'
```

### Advanced parameter types

Terminal

```
# Byte array parameters
chr query my_query 'arg=x"AB12"'

# Using -- to avoid additional quotes
chr query my_query -- arg1=foo arg2=x"AB12"

# Dictionary/map parameters
chr query my_query 'arg=["key": 12]'

# Array parameters
chr query my_query 'arg=[foo, 123]'
```

## Testing against deployed dapps

### Testnet queries

Terminal

```
# Basic query on deployed dapp
chr query --network testnet --blockchain my_rell_dapp hello_world

# Query with parameters on deployed dapp
chr query --network testnet --blockchain my_rell_dapp my_query foo=17 bar=hello
```

## Next steps

After mastering queries:

1. [Run operations](https://docs.chromia.com/build/cookbook/cli/run-operations/) to modify blockchain state
2. [Run tests](https://docs.chromia.com/build/cookbook/cli/run-tests/) to verify your queries work correctly
3. [Deploy your dapp](https://docs.chromia.com/build/cli/commands/deployment/) to make queries available publicly

[View this page on docs.chromia.com](https://docs.chromia.com/build/cookbook/cli/run-queries/)Content mirrored from the live docs
