Docs
chromia.com

Deploy your dapp to testnet

On this page

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

Prerequisite

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 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)
  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:

      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.

    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.

  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.

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.