Language

The final step is to register the HAT with the DEX to allow it to connect dataplugs, sign up for offers and otherwise become a member of the HAT ecosystem.

The 2 parameters passed to DEX are * hatAddress - containing the fully-qualified address of the HAT. * applicationId - the id of the application assigned to you during the onboarding process.

All other details (such as the HAT’s public key) are fetched by DEX or registration fails if the HAT is not available.

curl --request POST \
  --url https://dex.hubofallthings.com/api/users/registerHat \
  --header 'content-type: application/json' \
  --data '{"hatAddress":"testhat.hubat.net","applicationId":"myApplicationId"}'
var data = JSON.stringify({
  "hatAddress": "testhat.hubat.net",
  "applicationId": "myApplicationId"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://dex.hubofallthings.com/api/users/registerHat");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://dex.hubofallthings.com/api/users/registerHat",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"hatAddress\":\"testhat.hubat.net\",\"applicationId\":\"myApplicationId\"}",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://dex.hubofallthings.com/api/users/registerHat"

payload = "{\"hatAddress\":\"testhat.hubat.net\",\"applicationId\":\"myApplicationId\"}"
headers = {'content-type': 'application/json'}

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
require 'uri'
require 'net/http'

url = URI("https://dex.hubofallthings.com/api/users/registerHat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\"hatAddress\":\"testhat.hubat.net\",\"applicationId\":\"myApplicationId\"}"

response = http.request(request)
puts response.read_body