Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
eth-json-rpc-middleware
Advanced tools
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.
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
});
web3-provider-engine is a tool for composing Ethereum provider middleware. It allows you to create custom providers by combining various middleware components. Compared to eth-json-rpc-middleware, web3-provider-engine offers a more extensive set of middleware options and is widely used in the Ethereum ecosystem.
json-rpc-engine is a framework for building JSON-RPC servers and clients. It provides a flexible way to compose middleware for handling JSON-RPC requests. While eth-json-rpc-middleware focuses specifically on Ethereum JSON-RPC methods, json-rpc-engine is more general-purpose and can be used for any JSON-RPC-based application.
eth-rpc-errors is a package for creating and handling Ethereum JSON-RPC errors. It provides a set of standard error codes and utilities for managing errors in Ethereum JSON-RPC applications. Unlike eth-json-rpc-middleware, which focuses on middleware for handling requests, eth-rpc-errors is specialized in error management.
Ethereum-related middleware for json-rpc-engine
.
See tests for usage details.
yarn test
FAQs
Ethereum-related json-rpc-engine middleware.
The npm package eth-json-rpc-middleware receives a total of 55,896 weekly downloads. As such, eth-json-rpc-middleware popularity was classified as popular.
We found that eth-json-rpc-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.