Introduction
An important aspect of Radix metadata standards is the concept of a dApp Definition. This is an account which acts as the unique on-ledger identifier for a decentralized application.
The dApp definition provides information about the dApp, and is a hub to establish trusted two-way links with other entities (resources, components and packages) and websites which form part of the dApp. This allows the Radix wallet to give appropriate guidance to the user, for example by telling the user the dApps they are interacting with during transaction signing.
There is a tool on the developer console to help with setting up and validating the entity metadata. See the dApp Definition Setup Guide for more information.
The resolved links are returned by the /state/entity/details endpoint on the Gateway API.
Overview
The dApp definition account forms the “hub” in a hub-and-spoke model. It acts as a container for metadata, and also for different types of links, discussed in more depth below.
Direct Links are links between a dApp and an entity, configured at each end with metadata.
Origin Links are links between a dApp definition and an https origin. On the dApp definition side it is configured by metadata, and on the origin side it is configured with a
/.well-known/radix.json
file hosted at the root.Blueprint Links are indirect links between a dApp definition and all components instantiated from an approved blueprint.
Partner Links are links between two different dApp definition accounts, configured at each end with metadata.
The Primary Locker is a link from a dApp definition to a single account locker, and used by the wallet to auto-discover claims for the user’s accounts for dApps they have previously interacted with.
Metadata Standards for Verification
The following details the various fields of metadata that should be configured on your on-ledger entities that make up your dApp – including the dApp Definition “hub”, and the various resource, component, and package “spokes”.
dApp Definition Accounts
To start, the dApp Definition account is configured with information metadata, according to the Metadata Standards for Wallet Display:
The
name
field should be set to aString
The
description
field should be set to aString
The
icon_url
field should be set to aUrl
The
tags
field should be set to aString[]
The following metadata entries should then be set for verification purposes:
Metadata field | Type | Contents | Gateway & Radix Wallet treatment |
---|---|---|---|
|
| “dapp definition” | Indicates that the metadata of this account should be read as a dapp definition, including looking for the metadata below, rather than treated as a user account. |
|
| Addresses of related entities. |
|
|
| Origins (URLs without any path) of associated websites. |
|
|
| dApp definition account addresses. |
|
|
| Primary Account Locker for the dApp |
|
Resources
Warning: Plural field name
Unlike components and packages, a resource is permitted to link to multiple dApp definitions, so it uses the plural metadata name
dapp_definitions
Metadata field | Type | Contents | Gateway & Radix Wallet treatment |
---|---|---|---|
|
| dApp definition account address(es) that have claimed this as a related resource, to confirm the claim. | Defines a direct link to the dApp if the resource’s address is also present in the dApp Definition Account’s Allows display of which dApp(s) this resource is associated with.
|
Packages
Metadata field | Type | Contents | Gateway & Radix Wallet treatment |
---|---|---|---|
|
| The dApp definition account address. | Defines a direct link to the dApp if the component’s address is also present in the dApp Definition Account’s |
|
| The names of blueprints in this package for which all components instantiated from that blueprint should be treated as being part of the dApp. | If the package is two-way linked to a dApp definition, then any components instantiated from the defined blueprint names are treated as being part of the dApp (unless they directly link to a different dApp). dApp owners should only configure this for blueprints where they wish all such components to be associated with their dApp:
|
Components
Direct Link
A direct link can be defined between a dApp definition and a scrypto component or “native component” such as a pool, account, validator or access controller.
Metadata field | Type | Contents | Gateway & Radix Wallet treatment |
---|---|---|---|
|
| The dApp definition account address. | Defines a direct link to the dApp if the component’s address is also present in the dApp Definition Account’s |
Blueprint Link
A component is treated as having a blueprint link to a dApp definition if both:
Its package is two-way linked to the dApp definition
Its package has the
enable_blueprint_linking
metadata entry set to include the component’s blueprint name.
Resolved Link
The “resolved link” is the primary link shown for a dApp. It resolves as the direct link, if it exists; otherwise the blueprint link.
The resolved link is used by the wallet to show the associated dApps using transaction signing.
Linking website to a dApp Definition
It is required by the Radix Wallet that a dApp Website have a correctly configured dApp Definition.
In development, you can configure your wallet to developer mode to disable these checks
Linking a website origin back to a dApp Definition
To declare a website (or websites) as part of a dApp, the dApp Definition sets a claimed_websites
metadata field (which should have a value of Vec<Origin>
).
If more than one website is specified, the first website listed should be the preferred entry point for users. A client like the Radix Wallet might link to this first website if the full listing of websites is not shown.
For websites, the developer must create a radix.json
file and expose it according to the RFC 8615: Well-known URI standard at /.well-known/radix.json
under their origin. When a request is made by a given dApp defintion from an origin to the Radix wallet, the Radix wallet will read this file and check for a two-way link with the given dApp definition.
For example, if a dApp Definition metadata identified the origin https://test.topradixdevs.io
it would look for confirmation of the link in an entry at https://test.topradixdevs.io/.well-known/radix.json
Origins and www
A dApp Definition is connected to one or more “claimed_websites”. From these, the origin is extracted, and used for the below two-way verification. This follows the web security model of the same-origin policy, where security-related data is sandboxed by origin.
Note in particular that
https://www.my-cool-radix-dapp.com
is a separate origin tohttps://my-cool-radix-dapp.com
- if you wish to support users using both, you need to either:
(a) Register both as claimed websites on your dApp Definition. The first in the list in the link will be the preferred link which is displayed to users.
(b) Choose a canonical origin (e.g. with the
www.
), and set up a redirect from the other origin. Only the canonical origin needs to then be registered.Typically (b) is a better choice as it fits better with the same-origin policy for other web security concerns, but (a) is also possible.
A radix.json
file for a domain hosting 2 dApps would be structured like this:
{
"dApps":[
{
"dAppDefinitionAddress": "account_rdx1qluj95c7hduuvrt5jctcj059qfavznygcssrgnuk0k6q3cktjy"
},
{
"dAppDefinitionAddress": "account_rdx1q7u4e5vry33qyddxpm0fhqspl5ruym7zx9kj9h0d52qsf4jc9p"
}
]
}
Note, while this means that one domain can host multiple dApps, there is no enforcement of separation of these dApps – it is assumed that each domain owner is in control of all dApps hosted on that domain. Each dApp must be listed in the radix.json
file at the root level of their domain to be considered valid, and it is up to each dApp to correctly declare which dApp Definition it is associated with under that domain.
Using this information on the website and on the dApp Definition, the Radix Wallet can verify that requests from websites are genuine. The Wallet will know each dApp by its dApp Definition address, and no website can falsely claim to be associated with a dApp Definition that it does not actually control.
Gumball Club Example
dApp URL is: https://gumball-club.radixdlt.com/ which gives an origin of https://gumball-club.radixdlt.com
Well Known
radix.json
file: https://gumball-club.radixdlt.com/.well-known/radix.jsonDashboard Examples: Current dApp Definition metadata | Transaction which set up the claimed_websites