HTTP API

DeNS Query provides an HTTP interface for accessing the UTxOs stored in the database.

Authentication

Some endpoints provided by DeNS Query are exposed internal functionalities to and are made available to facilitate testing and development.

Important

To prevent malicious interactions/modifications of DeNS Query’s database, it is therefore expected that these endpoints must NOT be exposed publicly (i.e., not accessible to end-users). For this to be effective, a HTTPS reverse proxy may be used to:

  • ensure that proper encryption is enforced;

  • guarantee host authentication; and

  • make sure that only user-specific endpoints are exposed for the public.

Below is a list of these internal endpoints that should not be exposed in the public API:

HTTP Endpoints

POST Query Set Insertion UTxO

Method

POST

URL

/api/query-set-insertion-utxo

Returns the UTxO to spend in order to purchase the given domain from the smart contracts.

Example request
{
    "name": "7461796C6F7273776966742E636F6D" (1)
}
  1. Hex encoded domain name one wishes to purchase

Example response
{
    "name": "Ok",
    "fields":
        [
            {
                "name": "676F6F676C652E636F6D", (1)
                "pointer":                      (2)
                    {
                        "currency_symbol":
                            "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
                        "token_name": ""
                    },
                "txOutRef":                     (3)
                    {
                        "txOutRef":             (4)
                            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                        "txOutRefIx": 69        (5)
                    }
            }
        ]
}
  1. Hex encoded largest purchased domain name which is lexicograpically strictly less than the provided domain name.

  2. Asset class which identifies the UTxOs of RRs

  3. Transaction output that this information resides at

  4. Hex encoded transaction hash

  5. Integer index

Errors

Code

Message

Description

400

Domain name already exists error response

Thrown if the domain name to purchase has already been purchased

500

No set elements found

Thrown if there are no UTxOs to spend in the set (most likely a misconfigured protocol)

Domain name already exists error response
No set elements found

POST Protocol UTxO

Method

POST

URL

/api/query-protocol-utxo

Returns the UTxO which holds the Protocol type i.e., trusted information of the DeNS protocol.

Example request
{ }
Example response
{
    "name": "Ok",
    "fields":
        [
            {
                "txOutRef":                     (1)
                    {
                        "txOutRef":             (2)
                            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                        "txOutRefIx": 69        (3)
                    },
                "protocol":                     (4)
                    {
                        "elementIdMintingPolicy":
                            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                        "setElemMintingPolicy" :
                            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                        "setValidator":
                            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                        "recordsValidator":
                            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                    }
            }
        ]
}
  1. Transaction output that this information resides at

  2. Hex encoded transaction hash

  3. Integer index

  4. JSON object of hex encoded script hashes (28 bytes)

Errors

Code

Message

Description

500

No protocol utxo found

Thrown if there is no UTxO for the protocol

No protocol utxo found

POST Set Protocol NFT

Method

POST

URL

/api/set-protocol-nft

Sets the protocol NFT to the provided protocol NFT returning the new protocol NFT that DeNS Query now follows. In other words, recalling that all instances of the DeNS protocol are uniquely identified by a protocol NFT, setting the protocol NFT to a new protocol NFT therefore changes the instance of the DeNS protocol that this DeNS Query server follows.

Example request
{
    "protocolNft":
        {
            "currency_symbol":
                "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
            "token_name":
                ""
        }
}
Example response
{
    "name": "Ok",
    "fields":
        [
            {
                "protocolNft":
                    {
                        "currency_symbol":
                            "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
                        "token_name":
                            ""
                    }
            }
        ]
}

LambdaBuffers

All datum described in the requests and responses in HTTP Endpoints have an associated LambdaBuffers type with generated JSON parsers. Details can be found in the LambdaBuffers schema file given below

LambdaBuffers schema file
module Dens.Server

import Prelude   (Eq, Json, Text)
import Plutus.V1 (TxOutRef, AssetClass, Bytes)
import Dens.Db   (DensProtocolUtxo, DensSetUtxo)

---------------------------------------------------
-- Response type
---------------------------------------------------

sum Response a
    = Ok a
    | Failed ResponseFailed

record ResponseFailed = { error: Text }

derive Eq (Response a)
derive Json (Response a)

derive Eq ResponseFailed
derive Json ResponseFailed

---------------------------------------------------
-- Set insertion request / response
---------------------------------------------------
record QueryDensSetInsertionUtxoRequest = { name : Bytes }
prod QueryDensSetInsertionUtxoResponse = (Response DensSetUtxo)

derive Eq QueryDensSetInsertionUtxoRequest
derive Json QueryDensSetInsertionUtxoRequest

derive Eq QueryDensSetInsertionUtxoResponse
derive Json QueryDensSetInsertionUtxoResponse

---------------------------------------------------
-- Set query request / response
---------------------------------------------------
-- TODO(jaredponn): implementing this would be useful for updates, but we don't
-- support this now.
-- record QueryDensSettxoRequest = { name : Bytes }
-- prod QueryDensSetUtxoResponse = (Response DensSetUtxo)
-- 
-- derive Eq QueryDensSetUtxoRequest
-- derive Json QueryDensSetUtxoRequest
-- 
-- derive Eq QueryDensSetUtxoResponse
-- derive Json QueryDensSetUtxoResponse

---------------------------------------------------
-- Protocol info query / response
---------------------------------------------------
-- TODO(jaredponn): LB doesn't like JSON objects for empty records. I'll PR
-- this in LB.
-- record QueryDensProtocolUtxoRequest = { }
prod QueryDensProtocolUtxoResponse = (Response DensProtocolUtxo)

-- derive Eq QueryDensProtocolUtxoRequest
-- derive Json QueryDensProtocolUtxoRequest

derive Eq QueryDensProtocolUtxoResponse
derive Json QueryDensProtocolUtxoResponse

---------------------------------------------------
-- Set protocol NFT query /response
---------------------------------------------------
record SetProtocolNftRequest = { protocolNft: AssetClass }
prod   SetProtocolNftResponse = (Response SetProtocolNftRequest)

derive Eq SetProtocolNftRequest
derive Json SetProtocolNftRequest

derive Eq SetProtocolNftResponse
derive Json SetProtocolNftResponse