Relysia
Relysia WalletAPI DocumentationGithub RepositoryDemo
  • Relysia SDK
  • Getting Started
    • Setup
    • API
    • Infrastructure
  • Wallets
    • Wallets
    • Mnemonic
    • Addresses
    • Metrics
    • Balance
    • History
  • Payments
    • Lookup
    • Sweep
    • URI
    • Transactions
    • Raw Transactions
    • Invoices
      • Create Invoice
      • Get Invoice
      • Pay Invoice
    • Payments
    • Asm
  • token
    • Basics
    • Token Issuance
    • NFT Issuance
    • Atomic Swaps
    • Details
    • Leaderboard
  • Utility
    • Post
    • Upload
    • Conversion
    • Paymail
    • Transpile-Compile
  • Enterprise Wallet
    • Overview
    • Authentication
    • Management
    • Wallet
    • Smart Contracts
    • Transaction
    • Fee Manager
    • Events
  • Realtime Transaction Notification
    • Use Case
    • Setup and Configuration
    • Events and Messages
  • More
    • Metashard
    • Satolearn
Powered by GitBook
On this page
  1. Realtime Transaction Notification

Setup and Configuration

Prerequisites and Setup

PreviousUse CaseNextEvents and Messages

Last updated 2 years ago

We require two packages to create a simple client application to receive notifications: 1. (For connectivity) 2. HTTP (For HTTP sending requests)

A typical simple application to get notification enabled is as depicted below. It's a two-step process.

  1. Authentication (/v1/auth) user

  2. Listen the specific event to receive relevant message\data -Listen for event the "notification" to receive transactional notifications -Listen for event the "balance" to receive balance changes -Listen for event the "history" to receive history changes

const axios = require('axios').default;
const { io } = require('socket.io-client')
            
const relysiaEndpoint = 'api.relysia.com';

(async () => {
    // Login into account
    const loginObject = await axios.post(`https://${relysiaEndpoint}/v1/auth`, {email: "user@abc.com", password: "password"});
    console.log('Login completed', loginObject.data);
    // Connect websocket for this account
    const socket = io(`wss://${relysiaEndpoint}`, {
        extraHeaders: {
            authToken: loginObject.data.data.token,
        },    
        transports: ['websocket', 'polling']
    });

    socket.on('error', function(error) {
        console.log("Connection Error: " + error.toString());
    });

     // Listen for message and log them as notification arrive
    socket.on('notification', function (message) {
        console.log('event received', message);
    })

    // listen for balance and log them on balance arrive
    socket.on('balance', function (balance) {
        console.log('event received', balance);
    })

    // listen for history and log them on history arrive
    socket.on('history', function (history) {
        console.log('event received', history);
    })
    
    

    socket.on('connect', function(connection) {
        console.log('WebSocket Client Connected');
        socket.on('close', function() {
            console.log('echo-protocol Connection Closed');
        });
    });
})()

socket.io-client
client-library