Skip to main content

Getting Started

Watchtower uses Websockets to stream down data from the Mirror Node.

For integration we will use a standard library Socket.io.

info

You will need:

  • Arkhia Watchtower URL
  • Arkhia API_KEY

Both the URL and API KEY can be retrieved from the Arkhia Dashboard after you Create a Project.

Don't have an account yet with Arkhia? Signup.

Connect to Watchtower and make sure all is running. Make sure you install socket.io package before by running:

npm install socket.io npm install socket.io-client (frontend apps)

import React, { useEffect, useState } from "react";import io from 'socket.io-client';function StreamingInit () {  const watchtowerURL = `https://<WATCHTOWER_URL>?api_key=<ARKHIA_API_KEY>`;  const socket = io(watchtowerURL, {      transports: ['websocket']  });  const [socketStatus, setSocketStatus] = useState(``);  useEffect(() => {      socket.on(`connect`, () => {          socket.on(`status`, (msg) => {              console.log(`status`, msg);              setSocketStatus(`Watchtower is successfully connected`);          });          socket.emit(`list-services`, (services: any) => {              console.log(`Listing available services`, services);          });      });      socket.on(`disconnect`, (msg: any) => {          setSocketStatus(`Watchtower is disconnected.`)          console.log(`Disconnected.`)      });      socket.on(`error`, (message: any) => {          console.error(message);          setSocketStatus(message)      })  }, [socket]);  return (      <>          <div>              {                  socketStatus && (                      <>                      <h6>Watchtower status</h6>                      <div>{socketStatus}</div>                      </>                  )              }          </div>      </>  );}export default StreamingInit;
info
At this moment, if you have a Growth account with the right config you should have a successfull connection.