Get a container for your dapp
In this section, you’ll complete the steps needed to obtain a container for your dapp.
Prerequisites
Ensure you have the following before proceeding:
- tCHR tokens: Required to lease a container. Follow the instructions in Get test tokens (tCHR) to obtain tokens. This step includes creating a Chromia account if you don’t already have one.
- Chromia CLI and a public-private key pair: Install Chromia CLI using the CLI installation guide, then generate a key pair specifically for the testnet container by following the steps below.
Step 1: Generate a key pair
With Chromia CLI installed, you’ll need to create a public-private key pair for your testnet container. This key pair is separate from the wallet key used to receive tCHR tokens. Run the following command and specify a key ID to keep it easily identifiable. For example:
chr keygen --key-id="testnet_container_key"
This command will save your key pair in the .chromia
folder:
- Public key:
.chromia/testnet_container_key.pubkey
- Private key:
.chromia/testnet_container_key
Using a custom key ID, like "testnet_container_key"
, helps you manage multiple keys and identify specific purposes
(e.g., for testnet use). If you use chr keygen
without specifying a key ID, it will default to chromia_key
. Be aware
that using this default key ID can risk overwriting the key if chr keygen
is run again without specifying an ID.
Keep your private key secure. You may share the public key, but the private key should never be shared.
For more information, see the keygen documentation.
Step 2: Lease container space
With tCHR tokens in your account and your key pair ready, you can now lease a container.
- Go to the testnet staking page and connect your wallet.
- Open the My Containers section at the top of the page.
- Click Lease a new container.
- Choose an available container cluster and follow the prompts.
- Enter your public key: Locate your public key at
.chromia/testnet_container_key.pubkey
(or the filename you specified with--key-id
) and enter it when requested. - Complete the leasing process by signing the lease with MetaMask when prompted. Once the process is finalized, you’ll receive a Container ID, which is essential for deploying your dapp.
Keep track of your Container ID
You’ll need your Container ID later to deploy your dapp. Feel free to note it down or retrieve it anytime by going to the testnet staking page and navigating to My Containers.