Link Search Menu Expand Document

Developer Integration

Do you have some ideas for integrating Namesdao .xch Names into a project or application you’re building?

Namesdao API

Public API and interactive documentation are available here:

We do not duplicate the API docs on this site; please refer to the interactive docs for all endpoints.

Secondary Resolver

Your application can look up the details of a Namesdao .xch Name from Namesdao’s secondary resolver using a standard HTTP GET request. Note that Spacescan also resolves Namesdao .xch names, and anyone else may run an independent secondary resolver using the blockchain data.

sample file https://namesdaolookup.xchstorage.com/namesdao.json

sample sig https://namesdaolookup.xchstorage.com/namesdao.json.sig

You can confirm the authenticity of the .json file by checking the .sig file for our signature. Our PGP key is located in the Namesdao-cli project. You can view the public key in namesdao.py.

Our secondary name resolver now returns an extensive list of info on a .xch name, per the CHIP-0009 recommended standard.

Here is an example of file content (re-formatted to look pretty):

{
  "address": "xch1jhye8dmkhree0zr8t09rlzm9cc82mhuqtp5tlmsj4kuqvs69s2wsl90su4",
  "uris": [
    "https://storage1.xchstorage.cyou/namesdao/namesdao-4295111.jpg",
    "https://storage2.xchstorage.cyou/namesdao/namesdao-4295111.jpg",
    "ipfs://bafybeicwruritcgxdgbfu4d66pi3kotsb3z3cn4dork5z2l5kpvzzzvrcu/namesdao-4295111.jpg"
  ],
  "meta_uris": [
    "https://storage1.xchstorage.cyou/namesdao/namesdao-4295111.json",
    "https://storage2.xchstorage.cyou/namesdao/namesdao-4295111.json",
    "ipfs://bafyreiffjaedvr7x2xb7toew7zeuuu7ewkvqs43f4fmeyq4pjltutav4yi/metadata.json"
  ],
  "nft_coin_id": "78a0dd81c626fa7a530ca2e6eca02805097c8aeb369d85d177ac92fdf5827985"
}

After receiving the URL, you can parse it into a JSON object, and directly pull the address value from there.

If you have a full node, you can also verify the information with your local node using the nft_coin_id.

Python sample code

Here is some sample Python code for the simplest form of resolving an address from our secondary resolver. Note that it requires that the requests package be installed (“pip install requests”).

import json
import requests

name = "Gratitude"
namesdao_name = name.lower()
r = requests.get("https://namesdaolookup.xchstorage.com/" + namesdao_name + ".json")
json_name_info = json.loads(r.content)

address = json_name_info['address']

You can also refer to CHIP-0009 and NDIP-0002 for additional details

Cloaked registration memos (for hidden registrations)

Apps can submit a registration request without revealing the target name in the mempool by using a cloaked memo.

  • What it is

    • A memo that starts with :register: followed by a URL-encoded ASCII-armored OpenPGP message.
  • How to generate

    1. Build the plain-text payload as the exact .xch name you want to register (with your intended capitalization), e.g. Namesdao.xch.
    2. Encrypt that string with OpenPGP using the Namesdao PGP public key (the same one referenced in Namesdao-cli). Produce an ASCII-armored ciphertext.
    3. URL-encode the armored text.
    4. Prefix with :register:.
    5. Put this final string into the transaction memo field and send the standard registration amount to the registration address.
  • Registration address

    • xch1jhye8dmkhree0zr8t09rlzm9cc82mhuqtp5tlmsj4kuqvs69s2wsl90su4
    • Or you can request the registration address from the API if preferred
  • Minimal JavaScript example (OpenPGP.js)

// Pseudo-code; obtain the current Namesdao PGP public key from Namesdao-cli repo
// and keep it up to date in your integration.

async function makeCloakedMemo(name, armoredPublicKey) {
  const message = await openpgp.createMessage({ text: name });
  const pubKey = await openpgp.readKey({ armoredKey: armoredPublicKey });
  const armoredCiphertext = await openpgp.encrypt({
    message,
    encryptionKeys: pubKey,
  });
  return ":register:" + encodeURIComponent(armoredCiphertext);
}
  • Wallet memo encoding notes

    • Some wallets require memo bytes (hex-encoded) rather than plain UTF-8 text. For example, with Goby, hex-encode the UTF-8 string before attaching as memo.
    • Ensure no surrounding whitespace and that the name uses your intended capitalization.
  • Try it

    • You can interactively generate a cloaked memo at the dapp: https://dapp.namesdao.org/cloakedmemo.html

Downloading the Namesdao .xch Name NFT collection

You can potentially download the Namesdao .xch Name NFT collection from an explorer such as Spacescan or MintGarden. Just create an account and request an API key, as applicable, on those sites.

This approach can be used to generate statistics, indexes or secondary name resolvers.

Here is an example URL from the Spacescan API to download one page of names

https://api2.spacescan.io/api/nft/collection/col1u9pemm2avjcz8t9emhga4vys5knugsfnctpkk2jyx05jc8d6ch2swe4qvm?coin=xch&version=1&page=20