# Build and run · Chromia Docs (concept)

> In this topic, you'll build and deploy the Hello World dapp with the Chromia Command-line Interface (Chromia CLI).

Source: https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/

# Build and run

On this page

* [Prerequisites](#prerequisites)
* [CLI](#run-dapp-in-chromia-cli)
* [Run dapp in Chromia CLI](#run-dapp-in-chromia-cli)
* [VS Code](#run-dapp-in-vs-code)
* [Run dapp in VS Code](#run-dapp-in-vs-code)
* [Run a transaction](#run-a-transaction)
* [Optional Next steps](#optional-next-steps)

In this topic, you'll build and deploy the `Hello World` dapp with the
[Chromia Command-line Interface (Chromia CLI)](https://docs.chromia.com/build/cli/introduction/). Read more about the features of the Chromia CLI
in the [Chromia CLI command reference](https://docs.chromia.com/build/cli/commands/) section.

## Prerequisites

* Install Visual Studio Code; see [VS Code Installation Guide](https://code.visualstudio.com).
* Install PostgreSQL database; see [Set up PostgreSQL database](https://docs.chromia.com/get-started/installation/).
* Install Chromia CLI; see [Install and configure Chromia CLI](https://docs.chromia.com/get-started/installation/).

## Run dapp in Chromia CLI

Once you install the Chromia CLI, it's time to create a project.

1. Create the project folder in a path of your choice and use the `chr create-rell-dapp` command.

   Terminal

   ```
   chr create-rell-dapp
   ```

   The `chr create-rell-dapp` command creates a new [Rell](https://docs.chromia.com/rell/rell-intro/) structured project **`my-rell-dapp`** with
   the necessary files. A `main.rell` file, which includes the `Hello World` query and test files in the `src/test/`
   folder. You also have a standard configuration for your project in the `chromia.yml` file. For more information, see
   the [project config file](https://docs.chromia.com/build/configuration/project-config/).

   Terminal

   ```
   my-rell-dapp
      |--chromia.yml
      |--src
         |--main.rell
         |--test
            |--arithmetic_test.rell
            |--data_test.rell
   ```

   The next step is to start a [node](https://docs.chromia.com/get-started/about/architecture/node/) and run your app locally. You can do it in a
   couple of different ways, but the most straightforward method we recommend is the Chromia
   [CLI](https://docs.chromia.com/build/cli/commands/node/).
2. Start the node using the `chr node start` command inside the newly created project directory:

   Terminal

   ```
   cd my-rell-dapp
   chr node start
   ```

   The `chr node start` command starts a node with your applications running on it. All the blockchains listed in the
   `blockchains` key in the `chromia.yml` file get started.

   YAML

   ```
   blockchains:
     my_rell_dapp: <----- This is the blockchain that starts
       module: main <----- This is the entry point of the chain
   ```

   The node should now be running with a local blockchain. The terminal where you ran `chr node start` will display info
   messages about committed blocks and transactions. Any `print` statements in your Rell code will also appear there.

   The last step is to query your dapp and test that the backend works correctly.
3. Write the following in a new terminal with your project folder as the working directory.

   Terminal

   ```
   chr query hello_world
   ```

   note

   If your node is running on a URL other than the default `http://localhost:7740`, use the `--api-url` option with
   `chr query`.
4. Your terminal should show you the following message.

   Terminal

   ```
   "Hello World!"
   ```

   Great! You've successfully queried your dapp. Queries are read-only operations that retrieve data from the
   blockchain.
5. Now let's modify the data by running a transaction. Transactions (also called operations) can change the state of
   your dapp.

   First, generate a key pair to sign your transactions:

   Terminal

   ```
   chr keygen --key-id=chromia_key
   ```

   This creates a key pair in the `.chromia` folder in your home directory (`chromia_key`, `chromia_key.pubkey` and `chromia_key_mnemonic`) that will be used to sign
   transactions.
6. Run a transaction to change the name from "World" to "Developer":

   Terminal

   ```
   chr tx set_name "Developer"
   ```

   note

   If your node is running on a URL other than the default `http://localhost:7740`, use the `--api-url` option with
   `chr tx`.
7. Query again to see the change:

   Terminal

   ```
   chr query hello_world
   ```

   Your terminal should now show:

   Terminal

   ```
   "Hello Developer!"
   ```

Great job! The Rell backend is up and running and works as it should. You've learned how to:

* Query data from your dapp (read)
* Run transactions to modify data (write)
* Verify changes by querying again

You have now run a complete `Hello World` dapp in the Chromia CLI.

## Run dapp in VS Code

The extension enables language features for Rell, including syntax highlighting and compilation warnings. It contributes
the commands **Rell: New Template Project** and **Rell: Invalidate index caches**, which are available in the Command
Palette. Once you install the extension, it's time to create a project.

1. Open the Command Palette by going to the menu **View** - **Command Palette**. Type **Rell: New Template Project**.

   ![project template](https://docs.chromia.com/img/new_project_template_light.png)
2. The command **Rell: New Template Project** asks you to select the project type from the dropdown menu. Select
   **Minimal**.

   ![project template selection minimal](https://docs.chromia.com/img/new_project_template_minimal_light.png)
3. Next, you get **`my-rell-dapp`** as prefilled project name. Press **Enter** to create the project.

   ![project name](https://docs.chromia.com/img/new_project_name_light.png)

   It creates a new Rell structured project with the necessary files. A `main.rell` file, which includes the
   `Hello World` query and test files in the `src/test/` folder. You also have a standard configuration for your project
   in the `chromia.yml` file. For more information, see the [project config file](https://docs.chromia.com/build/configuration/project-config/).

   ![project folder](https://docs.chromia.com/img/new_project_template_folder_light.png)

   note

   Make sure to set the same password and username as your database instance if you didn't choose the default one from
   [Set up PostgreSQL database](https://docs.chromia.com/get-started/installation/). You can change this under the database attributes in the
   [project config file](https://docs.chromia.com/build/configuration/project-config/).
4. Use the **`Node start`** command to start the node.

   ![node start](https://docs.chromia.com/img/node_start_light.png)

   info

   This command starts a node that contains your app. For more information, see
   [Deploy your dapp to Testnet](https://docs.chromia.com/get-started/create-dapp/deploy-to-testnet/) or
   [node command](https://docs.chromia.com/build/cli/commands/node/).

   Locate the Blockchain RID in the terminal output. You need it to interact with your dapp. The Blockchain RID is the
   hex value following the Blockchain RID: tag. For example, see the following image.

   ![blockchain RID VS](https://docs.chromia.com/img/blockchainrid_light.png)

   The last step is to query your dapp and test that the backend is working correctly.

Run the following command to call the `hello_world` query defined in `main.rell`:

Terminal

```
chr query hello_world
```

You should see:

Terminal

```
"Hello World!"
```

Great! You've successfully queried your dapp. Queries are read-only operations that retrieve data from the blockchain.

### Run a transaction

Now let's modify the data by running a transaction. Transactions (also called operations) can change the state of your
dapp.

1. First, generate a key pair to sign your transactions. Run this command in the terminal:

   Terminal

   ```
   chr keygen --key-id=chromia_key
   ```

   This creates a key pair in the `.chromia` folder in your home directory (`chromia_key`, `chromia_key.pubkey` and `chromia_key_mnemonic`) that will be used to sign
   transactions.
2. Run a transaction to change the name from "World" to "Developer":

   Terminal

   ```
   chr tx set_name "Developer"
   ```
3. Query again to see the change:

   Terminal

   ```
   chr query hello_world
   ```

   You should now see:

   Terminal

   ```
   "Hello Developer!"
   ```

Great job! The Rell backend is up and running and works as it should. You've learned how to:

* Query data from your dapp (read)
* Run transactions to modify data (write)
* Verify changes by querying again

You have now run a complete `Hello World` dapp in VS Code.

## Optional Next steps

Now that your Rell backend is running, you can:

* **Connect a client** - Learn how to interact with your dapp from a frontend application
  + [JavaScript/TypeScript Hello World Quickstart](https://docs.chromia.com/build/clients/postchain-clients/javascript-typescript/hello-world-quickstart/)
* **Learn Rell** - Follow courses on the [Chromia learning platform](https://chromia.com/learn/)

[View this page on docs.chromia.com](https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/)Content mirrored from the live docs
