Registry / http-networking / ethjs-provider-http

ethjs-provider-http

JSON →
library0.1.6jsnpmunverified

ethjs-provider-http is a minimalist HTTP provider module for interacting with the Ethereum RPC layer, designed to adhere to the `web3` provider specification. It uses the `xhr2` module for its underlying HTTP requests. Released in 2016 and last updated to version 0.1.6 in January 2017, this package is part of the broader `ethjs` ecosystem, which aimed to provide a lightweight alternative to `web3.js` at the time. However, the `ethjs` suite is no longer actively maintained and has largely been superseded by modern Ethereum client libraries such as Ethers.js and the latest versions of Web3.js. There is no ongoing release cadence, and it is primarily of historical interest or for maintaining legacy applications that specifically depend on it. Its key differentiator was its simplicity and a modular approach within the `ethjs` family, but this is now overshadowed by its lack of maintenance and modern feature support.

npm install ethjs-provider-http
INSTALL
IMPORT
SIG · ETHJS-PROVIDER-HTT
E
ethjs-provider-http
http-networkingjavascriptv0.1.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpProvider
const HttpProvider = require('ethjs-provider-http');
import { HttpProvider } from 'ethjs-provider-http';
This package is CommonJS-only and does not provide ESM exports. Direct ESM imports will fail.

This example demonstrates how to instantiate an `HttpProvider` and use it with `ethjs-query` to fetch block information from an Ethereum RPC endpoint. It highlights the CommonJS `require` syntax used by the library.

const HttpProvider = require('ethjs-provider-http'); const Eth = require('ethjs-query'); // NOTE: Ropsten is deprecated. Use a current testnet like Sepolia or Goerli, // or a mainnet RPC endpoint from a service like Infura or Alchemy. const provider = new HttpProvider('https://mainnet.infura.io/v3/' + (process.env.INFURA_API_KEY ?? '')); const eth = new Eth(provider); eth.getBlockByNumber(45039930, true, (err, result) => { if (err) { console.error('Error fetching block:', err); return; } if (result) { console.log('Block data:', result); } else { console.log('Block not found or null result.'); } });
Debug
Known issues
breakingThis package is no longer actively maintained or developed. The last publish to npm was in January 2017, and the underlying `ethjs` ecosystem is largely inactive. It is highly recommended to migrate to modern, actively maintained libraries like Ethers.js or Web3.js for new projects.
fix
Migrate to `ethers.js` (`new ethers.providers.JsonRpcProvider('URL')`) or `web3.js` (`new Web3(new Web3.providers.HttpProvider('URL'))`).
affects: >=0.1.0
gotchaThe example code, and the library itself, often references deprecated Ethereum testnets like Ropsten. These networks are no longer active or supported by most RPC providers, leading to connection failures or incorrect data.
fix
Always use current, supported Ethereum networks (e.g., Sepolia, Goerli for testnets) and up-to-date RPC endpoints from services like Infura, Alchemy, or your own node.
affects: >=0.1.0
breakingCompatibility with modern Ethereum JSON-RPC specifications (e.g., EIP-1193 provider interface) and newer client features is not guaranteed due to the package's age and lack of updates.
fix
Use contemporary Ethereum client libraries that actively implement and maintain compatibility with the latest RPC standards and Ethereum evolution.
affects: >=0.1.0
gotchaAs an unmaintained package, `ethjs-provider-http` may contain unpatched security vulnerabilities. Using it in production environments is not recommended due to potential risks.
fix
Prioritize using well-maintained and actively audited libraries from reputable organizations within the Ethereum ecosystem.
affects: >=0.1.0
breakingThis library is strictly CommonJS (`require`) and does not support ES Modules (`import`). Attempting to use `import` syntax will result in errors.
fix
Ensure your project or environment is configured for CommonJS, or use the `require` syntax. For modern applications, consider libraries with full ESM support.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Invalid JSON RPC response: "<html>..."
The RPC endpoint responded with an HTML error page (e.g., 404 Not Found, 403 Forbidden) instead of a valid JSON-RPC payload, often due to an incorrect or deprecated URL, or missing API key.
fix
Verify the RPC endpoint URL is correct and active. Ensure any required API keys are included in the URL or headers as per the provider's documentation. Check your network connection.
TypeError: HttpProvider is not a constructor
Attempting to use `ethjs-provider-http` after an incorrect import, or in an environment where `require` does not correctly resolve the module.
fix
Ensure you are using `const HttpProvider = require('ethjs-provider-http');`. If using TypeScript, you might need `const HttpProvider = require('ethjs-provider-http').default;` or custom type declarations if the library doesn't provide them.
ERR_OSSL_EVP_UNSUPPORTED
Older Node.js modules, especially those dealing with cryptography or network protocols, can encounter OpenSSL issues with newer Node.js versions due to changes in cryptographic policies or default algorithms.
fix
Try running Node.js with `--openssl-legacy-provider` flag (e.g., `node --openssl-legacy-provider your-script.js`). This is a temporary workaround; the long-term solution is to use a modern, updated library.
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies
xhr2requiredUsed internally for making HTTP requests to the Ethereum RPC endpoint.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
ethjs-provider-http — npm install ethjs-provider-http · libregistry