Quick Start
Let's do a quick query to find $web3.
The ADA Handle Standard makes querying a Handle's location (and by extension, the corresponding address) very simple. On Cardano, all NFTs are minted under a Policy ID. The Policy ID can only be generated by the policy's private key, and therefore acts as a guarantee for the NFT being minted that no other NFT under the same name will also have the same Policy ID.
With this in mind, it is completely safe and definitive to query a Handle's name as long as you have the correct Policy IDs in your query.
To demonstrate just how easy this concept is, let's look for the Handle $web3.

Querying A Handle

Converting a Handle to an address is as simple as checking for the location of that Handle. Rather than typical custom address NFTs that associate an address with metadata, the Handle Standard assumes an associated address by reference.
In our example, we will query the location of the $web3 Handle using a the Blockfrost REST API, but you could query your own Cardano node (equipped with the Wallet API) just as easily.
Node
1
const handleName = 'web3';
2
const policyID = 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a';
3
4
// A blank Handle name should always be ignored.
5
if (handleName.length === 0) {
6
// Handle error.
7
}
8
9
// Convert handleName to hex encoding.
10
const assetName = Buffer.from(handleName).toString('hex');
11
12
// Fetch matching address for the asset.
13
const data = await fetch(
14
`https://cardano-mainnet.blockfrost.io/api/v0/assets/${policyID}${assetName}/addresses`,
15
{
16
headers: {
17
// Your Blockfrost API key
18
project_id: process.env.BLOCKFROST_API_KEY,
19
'Content-Type': 'application/json'
20
}
21
}
22
).then(res => res.json());
23
24
if (data?.error) {
25
// Handle error.
26
}
27
28
const [{ address }] = data;
29
console.log(address); // addr1qx3c9...
Copied!
And that's it! You can be certain that the resulting address will be accurate at the time of the query. Depending on your dApp, you may want to query the Handle's location on an interval to account for possible movement between wallets.
Copy link