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 deployment command.

Prerequisite

note

testnet supports Rell 0.12. Ensure that you are using Rell 0.12.

Deploy the dapp

The important files for the deployment of a dapp are as follows:

Begin with generating a public and private key pair that's available in a .secret file.

  1. Write the following command to create a .secret file with a generated key pair (privkey and pubkey).
chr keygen --save .secret

You find the public and private key in the created .secret file. You can copy and share the public key, while the private key should be kept as a secret in the .secret file.

#.secret
#Keypair generated using...
#Date
privkey=<privkey>
pubkey=<pubkey>

Once you have your key pair, you need to stake Chroma token to deploy a dapp to the current testnet.

  1. To stake Chroma token, follow the instructions on the Staking Page. Once you stake a minimum of 100 CHR, you can request a container ID. You need to use this container ID to deploy your dapp in the following example.
info

The current public testnet has limited capacity; therefore, it requires staking. This might change as we increase the capacity of the testnet.

Once you receive the container ID, the container gets deleted from the network unless you deploy a dapp within 48 hours. If that happens, you can return to the staking page and request a new container ID if there is still capacity.

Note that this is a testnet; data may not persist between testnet updates.

  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:
my_rell_dapp: #Name of the blockchain
module: main #Entrypoint to the project
deployments:
testnet: #Deployment Target name
brid: x"A7FBCA6FE0B3DF8320876C4A00247A27EE86405D027F9FDFDCBF6A088392889D" #Blockchain RID for the testnet management chain
url: https://testnet4.chromia.dev:7740 #Target URL for one of the nodes in the testnet
container: <ContainerID> #Container ID
  1. Write the following command to deploy a specific chain to a specific target.
chr deployment create --settings chromia.yml --network testnet --blockchain hello --secret .secret
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
  1. 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 Configure Client for Chromia Network 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"A7FBCA6FE0B3DF8320876C4A00247A27EE86405D027F9FDFDCBF6A088392889D"
url: https://testnet4.chromia.dev:7740
container: <ContainerID>
chains:
hello: x"<BlockchainRID>" #Dapp Blockchain RID
  1. Write the following command to update your dapp:
chr deployment update --settings chromia.yml --network testnet --blockchain hello --secret .secret

When updating a dapp, you use the same command as for deployment but with the dapp Blockchain RID included in the chromia.yml file. You aren't prompted with anything this time, but a snapshot file gets created, which is also the case for deployment.