# Deploy your dapp to testnet · Chromia Docs (concept)

> This topic covers deploying and updating a dapp with the Chromia CLI to the public testnet. For more information, see the deployment command.

Source: https://docs.chromia.com/build/deployment/testnet/deploy-dapp/

# Deploy your dapp to testnet

On this page

* [Prerequisite](#prerequisite)
* [Deploy the dapp](#deploy-the-dapp)
* [Update the dapp](#update-the-dapp)

This topic covers deploying and updating a dapp with the Chromia CLI to the public testnet. For more information, see
the [deployment command](https://docs.chromia.com/build/cli/commands/deployment/).

info

For information on deploying your dapp to the mainnet, see the
[Deploy your dapp to mainnet](https://docs.chromia.com/build/deployment/mainnet/deploy-dapp/) topic.

## Prerequisite

* Install Chromia CLI; see [Install and configure Chromia CLI](https://docs.chromia.com/get-started/installation/).
* Build a dapp that compiles; see
  [Build and run the Hello World dapp with Chromia CLI](https://docs.chromia.com/get-started/create-dapp/run-dapp-cli/).
* Container ID (follow the instructions on the
  [Get a container for your dapp](https://docs.chromia.com/build/deployment/testnet/get-container/) page to lease a container).

## Deploy the dapp

1. **Update `chromia.yml`**: Copy the `deployments` key below into your `chromia.yml` configuration file. Replace
   `<ContainerID>` with the **Container ID** you got from the [Chromia Testnet Vault](https://vault.testnet.chromia.com/containers/) when you leased a container.

   YAML

   ```
   deployments:
     testnet: # Deployment Target name
       brid: x"6F1B061C633A992BF195850BF5AA1B6F887AEE01BB3F51251C230930FB792A92" # Blockchain RID for Testnet Directory Chain
       url: https://node0.testnet.chromia.com:7740 # Target URL for one of the nodes in Testnet
       container: <ContainerID> # Replace with your container ID (Example - container: 15ddfcb25dcb43577ab311fe78aedab14fda25757c72a787420454728fb80304)
   ```

   info

   For verification of the `brid` and `url`, follow these steps:

   * Visit the [Chromia Explorer](https://explorer.chromia.com) and set **Current network** to **Testnet**.
   * Under **Clusters**, select **system**.
   * Copy an **API URL** from the bottom of the page (e.g., `https://node0.testnet.chromia.com:7740`) and use it as the
     `url`.
   * Under **System Chains**, click **directory\_chain** and copy the `brid`.
2. **Create a `config` file**: Create a configuration file to ensure the CLI knows which key to use.

   * Locate or create the `.chromia` folder in your home directory:

     + **Linux/macOS**: `~/.chromia/`
     + **Windows**: `C:\Users\<YourUsername>\.chromia\`
   * Inside this folder, create a file named `config` and add the following line:

     Plain text

     ```
     key.id = testnet_container_key
     ```

     This assumes you named your key `testnet_container_key` during the key generation step. If you used a different key
     ID, replace `testnet_container_key` with your chosen key ID.
   * Verify that the generated key files (`testnet_container_key` and `testnet_container_key.pubkey`) are present in the
     `.chromia` folder. If they are missing, re-run the key generation step using the instructions in
     [Generate a key pair](https://docs.chromia.com/build/deployment/testnet/get-container/#step-1-generate-a-key-pair).

   This file ensures the CLI uses the correct private key when deploying your dapp.
3. **Deploy your dapp**: Run the deployment command.

   Terminal

   ```
   chr deployment create --settings chromia.yml --network testnet --blockchain hello
   ```

   By default, this command reads the `keyId` from the configuration file located at `.chromia/config`.

   * **Windows:** `C:\Users\<YourUsername>\.chromia\config`
   * **macOS and Linux:** `/Users/<YourUsername>/.chromia/config` or `/home/<YourUsername>/.chromia/config`

   If you prefer to use a different configuration file, you can specify the path using the `--config` option:

   Terminal

   ```
   chr deployment create --settings chromia.yml --network testnet --blockchain hello --config <config file path>
   ```

   This allows you to set the `keyId` in a specific config file instead of the global configuration.

   info

   If you get an error while deploying your dapp, make some changes to your dapp code. Chromia uses dapp configuration
   and code to create the Blockchain RID, which must be unique for each dapp.
4. **Add the `chains` key to `chromia.yml`**: After a successful deployment, you get the dapp **Blockchain RID** as a
   prompt in the terminal. It identifies your dapp for future deployments (updates). The prompt could look as follows:

   YAML

   ```
   Deployment of blockchain hello was successful
   Add the following to your project settings file:
   deployments:
     testnet:
       chains:
         hello: x"<BlockchainRID>" #Dapp Blockchain RID
   ```

   Add the `chains` key with the `dapp name: **Blockchain RID**` from the prompt to the `chromia.yml` file. This is
   important for updating your dapp in the future.

## Update the dapp

Once you have done your first deployment, you can perform an update of your dapp.

info

The limitations on updating [Rell](https://docs.chromia.com/reference/terminology/#rell) entities are available
[here](https://docs.chromia.com/rell/language-features/modules/entity/#changing-entity-definitions).

Your `chromia.yml` must now have the `chains` config included.

YAML

```
blockchains:
  hello:
    module: main
deployments:
  testnet:
    brid: x"6F1B061C633A992BF195850BF5AA1B6F887AEE01BB3F51251C230930FB792A92"
    url: https://node0.testnet.chromia.com:7740
    container: <ContainerID>
    chains:
      hello: x"<BlockchainRID>" #Dapp Blockchain RID
```

Run the following command to update your dapp:

Terminal

```
chr deployment update --settings chromia.yml --network testnet --blockchain hello
```

By default, this command reads the `keyId` from the configuration file located at `.chromia/config`.

* **Windows:** `C:\Users\<YourUsername>\.chromia\config`
* **macOS and Linux:** `/Users/<YourUsername>/.chromia/config` or `/home/<YourUsername>/.chromia/config`

If you prefer to use a different configuration file, you can specify the path using the `--config` option:

Terminal

```
chr deployment update --settings chromia.yml --network testnet --blockchain hello --config config <config file path>
```

This allows you to set the `keyId` in a specific config file instead of the global configuration.

To learn more about developing production-ready dapps, visit the [Chromia course page](https://chromia.com/learn/).

warning

The deployed dapp will be accessible in about five minutes.

[View this page on docs.chromia.com](https://docs.chromia.com/build/deployment/testnet/deploy-dapp/)Content mirrored from the live docs
