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

web3-core-requestmanager

Package Overview
Dependencies
Maintainers
4
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-core-requestmanager

Web3 module to handle requests to external providers.

  • 1.10.4
  • legacy
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
405K
increased by12.88%
Maintainers
4
Weekly downloads
 
Created

What is web3-core-requestmanager?

The web3-core-requestmanager package is a core component of the Web3.js library, which is used to interact with Ethereum blockchain nodes. It provides the functionality to send JSON-RPC requests to Ethereum nodes and handle the responses. This package is essential for managing the communication between the client application and the Ethereum network.

What are web3-core-requestmanager's main functionalities?

Sending JSON-RPC Requests

This feature allows you to send JSON-RPC requests to an Ethereum node. In this example, a request is sent to get the current block number from the Ethereum node.

const Web3 = require('web3');
const RequestManager = require('web3-core-requestmanager');

const web3 = new Web3('http://localhost:8545');
const requestManager = new RequestManager(web3.currentProvider);

const payload = {
  jsonrpc: '2.0',
  method: 'eth_blockNumber',
  params: [],
  id: 1
};

requestManager.send(payload, (error, result) => {
  if (error) {
    console.error('Error:', error);
  } else {
    console.log('Block Number:', result.result);
  }
});

Batch Requests

This feature allows you to send multiple JSON-RPC requests in a single batch. In this example, two requests are sent: one to get the current block number and another to get the current gas price.

const Web3 = require('web3');
const RequestManager = require('web3-core-requestmanager');

const web3 = new Web3('http://localhost:8545');
const requestManager = new RequestManager(web3.currentProvider);

const batch = new web3.BatchRequest();

batch.add(requestManager.send({
  jsonrpc: '2.0',
  method: 'eth_blockNumber',
  params: [],
  id: 1
}, (error, result) => {
  if (error) {
    console.error('Error:', error);
  } else {
    console.log('Block Number:', result.result);
  }
}));

batch.add(requestManager.send({
  jsonrpc: '2.0',
  method: 'eth_gasPrice',
  params: [],
  id: 2
}, (error, result) => {
  if (error) {
    console.error('Error:', error);
  } else {
    console.log('Gas Price:', result.result);
  }
}));

batch.execute();

Other packages similar to web3-core-requestmanager

FAQs

Package last updated on 05 Feb 2024

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