Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@walletconnect/jsonrpc-utils

Package Overview
Dependencies
Maintainers
8
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/jsonrpc-utils

Utilities for JSON-RPC

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
359K
decreased by-3.19%
Maintainers
8
Weekly downloads
 
Created

What is @walletconnect/jsonrpc-utils?

@walletconnect/jsonrpc-utils is a utility library for working with JSON-RPC in the context of WalletConnect. It provides tools for creating, validating, and managing JSON-RPC requests and responses, which are essential for communication between clients and servers in a decentralized environment.

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

Creating JSON-RPC Requests

This feature allows you to create a JSON-RPC request. The `formatJsonRpcRequest` function takes a method name and parameters, and returns a properly formatted JSON-RPC request object.

const { formatJsonRpcRequest } = require('@walletconnect/jsonrpc-utils');

const request = formatJsonRpcRequest('eth_sendTransaction', [{ from: '0x...', to: '0x...', value: '0x...' }]);
console.log(request);

Validating JSON-RPC Responses

This feature allows you to validate JSON-RPC responses. The `isJsonRpcResponseSuccess` function checks if a response is successful, while `isJsonRpcResponseError` checks if it contains an error.

const { isJsonRpcResponseSuccess, isJsonRpcResponseError } = require('@walletconnect/jsonrpc-utils');

const response = { jsonrpc: '2.0', result: '0x1', id: 1 };
console.log(isJsonRpcResponseSuccess(response)); // true
console.log(isJsonRpcResponseError(response)); // false

Handling JSON-RPC Errors

This feature allows you to create a JSON-RPC error response. The `formatJsonRpcError` function takes an id and an error message, and returns a properly formatted JSON-RPC error object.

const { formatJsonRpcError } = require('@walletconnect/jsonrpc-utils');

const error = formatJsonRpcError(1, 'Something went wrong');
console.log(error);

Other packages similar to @walletconnect/jsonrpc-utils

Keywords

FAQs

Package last updated on 17 May 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