5.6.22 • Published 3 years ago

ethers-axios-batch-provider v5.6.22

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

ethers-axios-batch-provider

Build Status NPM Package Version NPM Package Downloads Known Vulnerabilities GitHub Views GitHub Clones License: MIT

About

Fastest, fault tolerant multi node ethers.js compatible JSONRPC Batch provider

AxiosBatchProvider is an easy to use ethers.js v5 compatible Ethereum Javascript (Typescript) JSONRPC API Provider powered by a powerful Axios HTTP client wrapped by axios-auto library to help your automated error handling & Promise.any powered client-side load balancing feature.

It supports sending several Request objects and will expect to receive array of retun objects following the specification of Batching by JSON RPC 2.0.

Features:

  • Provides much better error handling & timeouts for public RPC nodes the most widely used HTTP client Axios.
  • Supports custom http.agent / https.Agent via Axios (Node.js feature to support Tor, Socks5, Https proxy connection)
  • Client side load-balancer using Promise.any() to resolve fastest query result from the fastest node connection.
  • Sends a query to multiple nodes (like Promise.all but without waiting for every promise to resolve)
  • Advanced retries for server-side error using axios-auto
  • Return cached eth_chainId value since network doesn't change for RPC nodes for most cases.

Installation

Node.js

# Wouldn't work without axios or ethers installed
npm i --save axios ethers ethers-axios-batch-provider

Documentation

https://ayanamitech.github.io/ethers-axios-batch-provider

Usage

Browser

Every release of ethers-axios-batch-provider will have new build of ./dist/browser/index.js for use in the browser. To get access to module classes use AxiosBatchProvider global variable.

WARN: We recommend hosting and controlling your own copy for security reasons

<!-- Since Browser bundle comes with axios-auto built in, no need to add additional axios or axios-auto dependency -->
<script src="https://cdn.jsdelivr.net/npm/ethers-axios-batch-provider@latest"></script>
<!-- Since Browser bundle comes with axios-auto built in, no need to add additional axios or axios-auto dependency -->
<script src="https://unpkg.com/ethers-axios-batch-provider@latest"></script>

Note that it would be helpful to setup the Subresource Integrity hash to ensure that the imported library has the desired codes.

For more info, see https://www.srihash.org/.

Node.js

// CommonJS
const AxiosBatchProvider = require('ethers-axios-batch-provider');

// ModuleJS / TypeScript
import AxiosBatchProvider from 'ethers-axios-batch-provider';

const provider = new AxiosBatchProvider('rpc-host-here');

Promise.all([
  provider.getBlockNumber(),
  provider.getBlock('latest'),
  provider.getBlockWithTransactions('latest')
]).then(result => console.log(result));
5.6.22

3 years ago

5.6.21

3 years ago

5.6.20

3 years ago

5.6.19

3 years ago

5.6.18

3 years ago

5.6.17

3 years ago

5.6.16

3 years ago

5.6.15

3 years ago

5.6.14

3 years ago

5.6.13

3 years ago

5.6.11

3 years ago

5.6.10

3 years ago

5.6.9

3 years ago