
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
@walletconnect/jsonrpc-http-connection
Advanced tools
@walletconnect/jsonrpc-http-connection is a package that provides a JSON-RPC connection over HTTP. It is part of the WalletConnect suite of tools and is used to facilitate communication between clients and servers using the JSON-RPC protocol over HTTP.
Create a JSON-RPC HTTP Connection
This feature allows you to create a JSON-RPC HTTP connection to a specified URL. The code sample demonstrates how to create a connection and make a request to get the current block number from an Ethereum node.
const { JSONRPC } = require('@walletconnect/jsonrpc-http-connection');
const connection = new JSONRPC('https://example.com/jsonrpc');
connection.request({
method: 'eth_blockNumber',
params: []
}).then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
Handle JSON-RPC Responses
This feature allows you to handle JSON-RPC responses, including error handling. The code sample demonstrates how to check for errors in the response and handle them appropriately.
const { JSONRPC } = require('@walletconnect/jsonrpc-http-connection');
const connection = new JSONRPC('https://example.com/jsonrpc');
connection.request({
method: 'eth_blockNumber',
params: []
}).then(response => {
if (response.error) {
console.error('Error:', response.error);
} else {
console.log('Result:', response.result);
}
}).catch(error => {
console.error('Request failed:', error);
});
json-rpc-engine is a modular JSON-RPC middleware engine for Node.js. It allows you to create a JSON-RPC server with custom middleware. Compared to @walletconnect/jsonrpc-http-connection, json-rpc-engine provides more flexibility in terms of middleware customization and server-side handling.
jayson is a JSON-RPC 2.0/1.0 client and server library for Node.js. It supports both HTTP and WebSocket transports. Compared to @walletconnect/jsonrpc-http-connection, jayson offers a more comprehensive solution for both client and server implementations of JSON-RPC.
node-json-rpc is a simple JSON-RPC 2.0 server and client library for Node.js. It provides basic functionalities for creating JSON-RPC servers and clients. Compared to @walletconnect/jsonrpc-http-connection, node-json-rpc is more lightweight and straightforward, making it suitable for simpler use cases.
FAQs
HTTP Connection for JSON-RPC
The npm package @walletconnect/jsonrpc-http-connection receives a total of 330,421 weekly downloads. As such, @walletconnect/jsonrpc-http-connection popularity was classified as popular.
We found that @walletconnect/jsonrpc-http-connection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.