Index names

Building an indexer

These instructions explain the protocol logic and instructions for extracting and validating names so you can properly index them and determine the first instance of each name.

Fetch the data

These instructions assume you have access to the entire ordinals data structure with basic details like content type, ID, as well as the content.

Validate that the inscription's content type is any of these:

  • text/plain

  • application/json

Fetch text as the raw text contents of an inscription. For example, text would be the raw contents returned at this Ordinals.com URL.

Validate names

The first instance of each name is the only valid instance of the name in the Sats Name System. We determine which name is first by inscription number. The following instructions will tell you how to extract and validate the name so you can compare inscription number and determine the first.

Extracting the name from JSON5

  1. Validate the text according to the JSON5 standard. To check if the inscription is JSON, try parsing the text. If an error is thrown (invalid JSON), skip to the "plain text" instructions listed under Validate Names.

  2. Check that the JSON has the required keys:

    • p equals "sns"

    • op equals "reg"

    • name is present and is type string

  3. Once name is extracted, follow the steps proceed to the Validate names steps.

Trailing commas are valid in JSON5. New lines inside values are not valid.

Validate names

  1. Validate utf-8 characters

  2. Turn the string into lowercase

  3. Delete everything after the first whitespace or newline (\n)

  4. Trim all whitespace and newlines

  5. Validate that there is only one period (.) in the name

Fetch namespaces

The first instance of each ns operation is the only valid instance in the Sats Name System. We determine which operation is first by inscription number.

Extract namespace operations

  1. Validate the text according to the JSON5 standard.

  2. Check that the JSON has the required keys:

    • p equals "sns"

    • op equals "ns"

    • ns is present and is type string

Validate namespace

  1. Validate utf-8 characters

  2. Turn the string into lowercase

  3. Validate that there is no period (.) in the namespace

Indexer & API

If you have a valid namespace or name compare to all other instances of the identical string. The first instance according to inscription number is the only valid name/namespace, or the "first" of this name.

Make sure you convert all queries to lowercase, otherwise you might inadvertently show name as available when they are registered.

Make sure your API returns a decoded version of the UTF-8 name. Scammers hide hidden characters inside names and by including this information clients can flag deceptive names.

Clients

Queries for names that include # and ? will fail unless you convert them to URL encoding reference first.

Last updated