Socket
Socket
Sign inDemoInstall

@walletconnect/jsonrpc-ws-connection

Package Overview
Dependencies
Maintainers
10
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/jsonrpc-ws-connection

WS Connection for JSON-RPC


Version published
Weekly downloads
327K
increased by4.32%
Maintainers
10
Weekly downloads
 
Created

What is @walletconnect/jsonrpc-ws-connection?

@walletconnect/jsonrpc-ws-connection is a package that provides a WebSocket connection for JSON-RPC communication. It is part of the WalletConnect protocol, which enables secure communication between decentralized applications (dApps) and wallets.

What are @walletconnect/jsonrpc-ws-connection's main functionalities?

Establishing a WebSocket Connection

This feature allows you to establish a WebSocket connection to a specified URL. The code sample demonstrates how to create a new WSConnection instance, set up event listeners for 'open' and 'close' events, and open the connection.

const { WSConnection } = require('@walletconnect/jsonrpc-ws-connection');

const connection = new WSConnection('wss://example.com');

connection.on('open', () => {
  console.log('Connection opened');
});

connection.on('close', () => {
  console.log('Connection closed');
});

connection.open();

Sending JSON-RPC Requests

This feature allows you to send JSON-RPC requests over the established WebSocket connection. The code sample shows how to send a JSON-RPC request once the connection is open.

const { WSConnection } = require('@walletconnect/jsonrpc-ws-connection');

const connection = new WSConnection('wss://example.com');

connection.on('open', () => {
  const request = {
    jsonrpc: '2.0',
    method: 'example_method',
    params: [],
    id: 1
  };
  connection.send(request);
});

connection.open();

Receiving JSON-RPC Responses

This feature allows you to receive and handle JSON-RPC responses from the WebSocket connection. The code sample demonstrates how to set up an event listener for 'message' events and parse the received JSON-RPC response.

const { WSConnection } = require('@walletconnect/jsonrpc-ws-connection');

const connection = new WSConnection('wss://example.com');

connection.on('message', (message) => {
  const response = JSON.parse(message);
  console.log('Received response:', response);
});

connection.open();

Other packages similar to @walletconnect/jsonrpc-ws-connection

Keywords

FAQs

Package last updated on 10 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc