User Guide for Socket Event Forwarder Plugin on Solar Blockchain

The Socket Event Forwarder plugin is designed to be installed on a Solar Relay blockchain node. It forwards real-time blockchain events through Socket.io V3 protocol to a custom application. This guide will show how to install and configure the plugin.

4 types of events can be generated:

  1. Realtime blockchain core events
  2. Transaction events after configurable confirmations
    • Useful for eccomerce payment system. We use this for our eccomerce store.
  3. Periodic CPU system status events
    • Remote monitoring of CPU performance
  4. Periodic Node status events
    • Remote monitoring of Blockchain Node’s performance

The plugin was developed by Friends of Little Yus member @emsy.
We use this plugin for many of our own applications and could be very useful for other members of the development community.
Developer Source: github.com/e-m-s-y/socket-event-forwarder

Table of Contents

    Configuration Options

    The plugin has several options available shown in the example below:

    {
        "package": "@foly/socket-event-forwarder",
        "options": {
            "enabled": true,
            "port": 3333,
            "events": [
                "block.applied",
                "round.applied",            
                "round.missed",
                "transaction.applied"
            ],
            "customEvents": [
                "transaction.confirmed",
                "systeminformation",
                "network.latency",
                "blockheight.current"
            ],
            "confirmations": [1, 5],
            "systeminformationInterval": 60000,
            "networkLatencyInterval": 600000,
            "blockheightCurrentInterval": 600000
        }
    }

    Available Options:

    “enabled”: enable/disable plugin.

    “port”: configure port for socket connections.

    “events”: configure the realtime blockchain events.
    Supported events https://github.com/Solar-network/core/blob/main/packages/core-kernel/src/enums/events.ts

    “customEvents”: Four custom events are available: Include in the list to enable.

    • “transaction.confirmed”: enables confirmed transaction events. Use “confirmations” option to configure.
    • “systeminformation”: enables CPU status events. Use “systeminformationInterval” option to configure interval
    • “network.latency”: enables periodic HTTP request latency test. Use “networkLatencyInterval” option to configure interval.
    • “blockheight.current”: enables periodic reporting of relay node’s blockchain height. Use option “blockheightCurrentInterval” to configure interval.

    “confirmations”: configure a list with the number of transaction confirmations that will generate an event.

    “systeminformationInterval”: configure interval in milliseconds

    “networkLatencyInterval”: configure interval in milliseconds

    “blockheightCurrentInterval”: configure interval in milliseconds

    Basic Configuration Settings

    The following is a basic configuration that can be used to send common events to an application.

    {
        "package": "@foly/socket-event-forwarder",
        "options": {
            "enabled": true,
            "port": 3333,
            "events": [
                "block.applied",
                "round.applied",
                "round.missed",
                "transaction.applied"
            ]
         }
    }

    Installation on Solar Relay

    Installation assumes that your Mainnet or Devnet relay node is installed and running. For security reasons we do not recommend using this plugin on a Forging Mainnet node.
    Mainnet Relay Installation
    Devnet Relay Installation

    Installation Method

    1. Open solarrc file and add alias line to it. Replace {user} with the user’s name: alias pnpm=”source /home/{user}/.solar/.env /home/{user}/.solar/.pnpm/bin/pnpm”
      nano ~/.solarrc
      Restart SSH session once added.
    2. From your non root user account go the plugin directory
      cd ~/solar-core/plugins
    3. Clone the plugin
      git clone https://github.com/e-m-s-y/socket-event-forwarder -b solar
    4. Go to plugin directory
      cd socket-event-forwarder
    5. Install plugin. Replace {user} with the user’s name
      source /home/{user}/.solar/.env; /home/{user}/.solar/.pnpm/bin/pnpm install
    6. Compile plugin. Replace {user} with the user’s name
      source /home/{user}/.solar/.env; /home/{user}/.solar/.pnpm/bin/pnpm compile
    7. Customize the plugin configuration to your needs. Add the configuration to the app.json file at the bottom of the relay.plugins section.
      Testnet configuration:
      nano ~/.config/solar-core/testnet/app.json
      Mainnet configuration:
      nano ~/.config/solar-core/mainnet/app.json
    8. Open port on firewall
      sudo ufw allow 3333
    9. restart relay
      solar relay:restart

    Correct Plugin Operation

    If the plugin is installed correctly then you should see similar log messages during relay startup:

    1|solar-relay  | [2022-02-21 23:33:17.572] INFO: Connecting to database: solar_devnet
    1|solar-relay  | [2022-02-21 23:33:18.121] DEBUG: Connection established.
    1|solar-relay  | [2022-02-21 23:33:19.446] INFO: [@foly/socket-event-forwarder] plugin registered, waiting to boot...
    1|solar-relay  | [2022-02-21 23:33:48.633] INFO: Webhook Server started at http://0.0.0.0:6004
    1|solar-relay  | [2022-02-21 23:33:48.636] INFO: [@foly/socket-event-forwarder] booting plugin...
    1|solar-relay  | [2022-02-21 23:33:48.650] INFO: [@foly/socket-event-forwarder] plugin booted and is ready for use

    You will then see messages whenever an event is triggered:
    1|solar-relay | [2022-02-21 23:34:16.600] DEBUG: [@foly/socket-event-forwarder] Forwarded event block.applied

    Socket Demo

    You can use our public server for testing without needing to install your own node.
    Mainnet: http://159.203.4.245:3333

    See our live demo and example for displaying block events on a website.
    https://www.friendsoflittleyus.nl/ark-bridgechain-plugins/socket-event-forwarder/