Skip to main content

Deploy your dapp to testnet

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

info

For information on deploying your dapp to mainnet, see the Deploy your dapp to mainnet topic.

Prerequisite

Deploy the dapp

  1. Copy the deployments key in the chromia.yml file example below into your config file. Replace the <ContainerID> with the Container ID you got from the staking page.

    blockchains:
    hello: #Name of the blockchain
    module: main #Entrypoint to the project
    deployments:
    testnet: #Deployment Target name
    brid: x"69035D70A99A6BFAF887E415352B40589F1AD1F8D2ADF848FE995B23A8EC2127" #Blockchain RID for the testnet management chain
    url: https://node0.projectnet.chromia.dev:7740 #Target URL for one of the nodes in the testnet
    container: <ContainerID> # Container ID (Example - container: 15ddfcb25dcb43577ab311fe78aedab14fda25757c72a787420454728fb80304)
    info

    The above example assumes you are deploying to ProjectNet. If you are deploying to HackNet, replace brid and url with the following values:

    brid: x"B06D83B5D2C7271B4E5906EED054BCD13F21CF3292E99E6C3158F1C544EB9882"
    url: https://node0.hacknet.chromia.dev:7740
  2. Execute the following command to deploy a specific chain to a specific target.

    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:

    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, then 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.

    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:

    Add the following to your project settings file
    deployments:
    testnet:
    chains:
    hello: x"<BlockchainRID>" #Dapp Blockchain RID
  3. 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.

Great. You have now done your first deployment. Please see the section Client setup if you want to configure the client code to connect to your deployed dapp.

Update the dapp

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

info

The limitations on updating Rell entities are available here.

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

blockchains:
hello:
module: main
deployments:
testnet:
brid: x"69035D70A99A6BFAF887E415352B40589F1AD1F8D2ADF848FE995B23A8EC2127"
url: https://node0.projectnet.chromia.dev:7740
container: <ContainerID>
chains:
hello: x"<BlockchainRID>" #Dapp Blockchain RID

Run the following command to update your dapp:

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:

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.