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

eth-json-rpc-middleware

Package Overview
Dependencies
Maintainers
7
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-json-rpc-middleware

Ethereum-related json-rpc-engine middleware.

  • 9.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
63K
decreased by-0.85%
Maintainers
7
Weekly downloads
 
Created

What is eth-json-rpc-middleware?

The eth-json-rpc-middleware package provides a collection of middleware functions for handling JSON-RPC requests in Ethereum-based applications. It is designed to be used with JSON-RPC servers to process and manage Ethereum JSON-RPC requests efficiently.

What are eth-json-rpc-middleware's main functionalities?

createScaffoldMiddleware

The createScaffoldMiddleware function allows you to create a middleware that scaffolds specific JSON-RPC methods with predefined responses. In this example, the middleware responds with a fixed block number for the eth_blockNumber method.

const { createScaffoldMiddleware } = require('eth-json-rpc-middleware');

const scaffoldMiddleware = createScaffoldMiddleware({
  eth_blockNumber: async (req, res, next, end) => {
    res.result = '0x1b4'; // Example block number
    end();
  }
});

createBlockRefRewriteMiddleware

The createBlockRefRewriteMiddleware function creates middleware that rewrites block reference parameters in JSON-RPC requests. This example sets the block reference to 'latest' for all requests.

const { createBlockRefRewriteMiddleware } = require('eth-json-rpc-middleware');

const blockRefRewriteMiddleware = createBlockRefRewriteMiddleware({
  blockRef: 'latest'
});

createRetryOnEmptyMiddleware

The createRetryOnEmptyMiddleware function creates middleware that retries JSON-RPC requests if the response is empty. This example configures the middleware to retry up to three times.

const { createRetryOnEmptyMiddleware } = require('eth-json-rpc-middleware');

const retryOnEmptyMiddleware = createRetryOnEmptyMiddleware({
  retryCount: 3
});

Other packages similar to eth-json-rpc-middleware

FAQs

Package last updated on 05 Oct 2022

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