Skip to main content

Deploy your dapp to Testnet

Run these commands from your Hello World project folder.

Get tCHR

You'll need a Web3 wallet such as MetaMask to sign requests.
Request tCHR tokens from the Chromia Testnet Faucet.

Lease a container

Generate a key pair for your Testnet container:

chr keygen --key-id="testnet_container_key"

Use the pubkey shown to lease a container. This gives you a Container ID.

Configure chromia.yml

Make sure the blockchain name is unique:

blockchains:
<blockchain_name>: # ← ensure this doesn't say 'my_rell_dapp' — use a unique name
module: main

Then add the Testnet deployment block and insert your Container ID:

deployments:
testnet:
brid: x"6F1B061C633A992BF195850BF5AA1B6F887AEE01BB3F51251C230930FB792A92"
url: https://node0.testnet.chromia.com
container: <container_id> # ← paste your Container ID here

Make the code unique

Your code must differ from anything previously deployed. Easy ways to make it unique:

module;

// A unique comment makes this build different.
// Example: deploy-uniq-xyz

object my_name {
// Or initialize with something unique:
// mutable name = "Alice_42"
mutable name = "World";
}

operation set_name(name) {
my_name.name = name;
}

// Random whitespace (blank lines or spaces) also counts as a unique edit:
// .
// .
// .....

query hello_world() = "Hello %s!".format(my_name.name);

Deploy

Deploy using the key ID from your generated key:

chr deployment create --network testnet --key-id testnet_container_key
If deployment is pending...

Use the printed tx-rid to fetch transaction status:

curl -X GET "https://node0.testnet.chromia.com/tx/6F1B061C633A992BF195850BF5AA1B6F887AEE01BB3F51251C230930FB792A92/{tx_rid}/status"

Replace {tx_rid} with the value shown by the CLI. Pattern (for reference): curl -X GET "{node}/tx/{directory_chain_brid}/{tx_rid}/status"

Deployment gives you the Blockchain RID to add under the chains tag in your chromia.yml:

deployments:
testnet:
brid: x"6F1B061C633A992BF195850BF5AA1B6F887AEE01BB3F51251C230930FB792A92"
url: https://node0.testnet.chromia.com
container: <container_id>
# Add chains tag with the Blockchain RID from the CLI output
chains:
<blockchain_name>: x"<blockchain_rid>"

Check it works

Using the blockchain name you defined in chromia.yml, set the name to "Deployer":

chr tx --network testnet --blockchain <blockchain_name> set_name "Deployer"

Hello Deployer! 👋

chr query --network testnet --blockchain <blockchain_name> hello_world