FOLLOW US:

Setting up Nostr NIP-05 on your own domain

Anyone with their own website can verify their own identity with Nostr for free. So…

  • People with vanity domains can validate their profiles.
  • Businesses can validate that they're the official account for that business.
  • Businesses can validate the accounts of their employees.
  • Membership sites (like this one) can validate the Nostr accounts of their members.

A technology projects go, it's actually pretty easy.

Where you need to set things up

You'll need to create a file on your server at the following path:

yourdomain.com/.well-known/nostr.json

It can be a static file or served by a script. What is important is that there be no CORS restrictions on the file. You accomplish that by setting Access-Control-Allow-Origin to a value of "*". That can be done in code or in an .htaccess file…

PHP code

header("Access-Control-Allow-Origin: *");

.htaccess

Header set Access-Control-Allow-Origin "*"

The file format

The file will be requested via the following URL:

https://yourdomain.com/.well-known/nostr.json?name =SomeName 

If they're requesting just the domain with no name they'll request this URL:

https://yourdomain.com/.well-known/nostr.json?name =_

You'll return a JSON file that looks like this…

{
  "names": {
    "s3x_jay": "667205eb525aa4a794859b2bd2bdd16e64ff57fd600880500fc53cdbf476439e"
  },
  "relays": {
    "667205eb525aa4a794859b2bd2bdd16e64ff57fd600880500fc53cdbf476439e":
      [ "wss://relay.s3x.social","wss://purplepag.es" ]
  }
}

That says that the (hex value) of my public key is a certain value. The Nostr client can then either look for me with that or they can confirm that that is indeed me (if someone is claiming to be s3x_jay@s3x.social). It also tells the person one or more relays they can use to find me. Telling about relays is recommended, but not mandatory.

[A brief aside about the purplepag.es relay… It's developed and run by PABLOF7z (not us) and it's aim is to have the most comprehensive list of profiles anywhere on Nostr. So it constantly queries other relays to find profile information. Putting it in your relay list will make loading profile information a lot faster and help other people find you.]

💡 Notice that the value in the names array becomes the key in the relays array.

The above file is if you're only returning for one account. If you're using a static file (not a script) and want to return information about multiple accounts you can return information about all the accounts - not just the one they ask about. That will look like this…

{
  "names": {
    "s3x_jay": "667205eb525aa4a794859b2bd2bdd16e64ff57fd600880500fc53cdbf476439e",
    "_": "b2bcb25e082dc002285bf7d06b1671b753021f3e369bcd5e7981c1aa6c6aec3e"
  }, 
  "relays": {
    "667205eb525aa4a794859b2bd2bdd16e64ff57fd600880500fc53cdbf476439e":
      [ "wss://relay.s3x.social","wss://purplepag.es" ],
    "b2bcb25e082dc002285bf7d06b1671b753021f3e369bcd5e7981c1aa6c6aec3e":
      [ "wss://relay.s3x.social","wss://purplepag.es" ]
  }
}

Clearly if you're dealing with multiple accounts a script is better so you don't give out info on every person in your organization.

Confused?

If all of that just seems horribly confusing - just sign up with us and get a s3x.social verified NIP-05 identifier! It's free, and for now it gives you free use of our Nostr relay (something you won't get if you do NIP-05 on your own domain).