Quick Vault listing (hardcoded metadata)
Fast and simple approach to list your dapp on the Chromia Vault using hardcoded metadata. Perfect for quick prototypes or simple dapps.
Prerequisites
- A deployed dapp on Chromia (Mainnet or Testnet)
- Media files for your dapp (icons, screenshots, etc.)
Implementation
Create a new module for Vault listing functionality. Copy this code into your quick_vault_listing.rell
file:
You only need to change the hardcoded values in the find_dapp_details
query to match your dapp's information. All
other parts can remain as shown.
module;
enum dapp_content_type {
landscape,
portrait,
promotional,
video,
icon
}
struct dapp_media {
name: text;
url: text;
type: dapp_content_type;
}
query find_dapp_details(dapp_rowid: rowid, requested_content_types: list<dapp_content_type>? = null) {
return (
rowid = 123, // random value
name = "<blockchain_name>",
description = "<description>",
launch_url = "<URL>",
genre = "<genre>",
chain_list = [
(
name = "<blockchain_name>",
brid = byte_array(
"<brid>"
), // brid of the deployed blockchain.
role = "<role>"
)
],
content = get_dapp_media(requested_content_types)
).to_gtv_pretty();
}
function get_dapp_media(requested_content_types: list<dapp_content_type>? = null): list<dapp_media>? {
val ec_media_tuple: list<(dapp_content_type, dapp_media)> = [
(
dapp_content_type
.icon,
dapp_media(
name = "icon1",
url = "https://filehub-gw.chromia.com/mainnet/ff03a1098eb24314ecd5277cbf352d480318f53191610079c377cb864fc23d8b",
dapp_content_type
.icon
)
),
(
dapp_content_type
.landscape,
dapp_media(
name = "landscape1",
url = "https://pbs.twimg.com/media/Gw8w9bJaQAIYo1A.jpg:large",
dapp_content_type
.landscape
)
),
(
dapp_content_type
.portrait,
dapp_media(
name = "portrait1",
url = "https://pbs.twimg.com/media/GxwgdGLb0AAvdHE?format=png&name=900x900",
dapp_content_type
.portrait
)
),
(
dapp_content_type
.promotional,
dapp_media(
name = "promotional1",
url = "https://pbs.twimg.com/media/GxwgdGLb0AAvdHE?format=png&name=900x900",
dapp_content_type
.promotional
)
),
(
dapp_content_type
.promotional,
dapp_media(
name = "promotional2",
url = "https://pbs.twimg.com/media/GxwgdGLb0AAvdHE?format=png&name=900x900",
dapp_content_type
.promotional
)
),
// Multiple promotional images
];
if (not empty(requested_content_types)) {
val media = list<dapp_media>();
for (type_requested in requested_content_types) {
for (tuple_media in ec_media_tuple) {
if (tuple_media[0] == type_requested) {
media.add(tuple_media[1]);
}
}
}
return if (media.size() > 0) media else null;
}
return null;
}
Customization
- Update dapp information: Change the placeholders in the
find_dapp_details
query - Add your media: Replace the placeholder URLs with your actual media URLs (use Filehub links or external image services)
- Add more media: Extend the
ec_media_tuple
list with additional media files
The hardcoded approach supports multiple images for the same content type (e.g., multiple promotional images). Simply
add additional entries to the ec_media_tuple
list with the same content type but different names and URLs.
Configuration
1. Include the module in your main Rell file
Add the following line to your main Rell file (e.g., main.rell
) to import the vault listing module:
import quick_vault_listing;
2. Update your chromia.yml
file
Update your chromia.yml
file to include the Vault listing module:
blockchains:
<blockchain_name>:
module: main
Deployment
Deploy your changes to either testnet or mainnet:
chr deployment update --network <deployment_name> --blockchain <blockchain_name>
Automatic listing
Once you implement the query and functions, your dapp will be automatically listed in the Chromia Vault based on the information it provides.
Making changes
To update your dapp's metadata, you must:
- Modify the hardcoded values in your code
- Redeploy your dapp using
chr deployment update
Verify the data
# Basic verification (no media content)
chr query --network <deployment_name> --blockchain <blockchain_name> --output-format json find_dapp_details dapp_rowid=0 'requested_content_types=[]'
# Get all media content
chr query --network <deployment_name> --blockchain <blockchain_name> --output-format json find_dapp_details dapp_rowid=0 'requested_content_types=["landscape", "portrait", "promotional", "video", "icon"]'
Optional: Storing media content on chain
If you want to store your media files on-chain for enhanced decentralization, you can use Filehub, Chromia's decentralized storage platform.
Consider using Filehub for decentralized media storage. Fixed cost of $0.10 per MB for perpetual storage with free access for everyone. Requires CHR tokens on the Economy Chain (minimum 1 CHR deposit).
Recommended image sizes:
- Horizontal image preview - 180px x 100px (recommended x3 - 540px x 300px)
- Vertical image preview - 180px x 240px (recommended x3 - 540px x 720px)
- Big image - 510px x 286px (recommended x3 - 1530px x 858px)
- Pagination image - 86px x 48px (recommended x3 - 258px x 144px)