# @chanceprotocol/etherplex

> Multicall with Ethers.js

Latest version **1.1.5** (published 2023-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @chanceprotocol/etherplex
pnpm add @chanceprotocol/etherplex
yarn add @chanceprotocol/etherplex
bun add @chanceprotocol/etherplex
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2023-08-17 |
| First published | 2023-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 113 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 63 |
| Author | Brendan Asselstine |
| Maintainers | chanceprotocol |

## Links

- npm: https://www.npmjs.com/package/@chanceprotocol/etherplex
- Repository: https://github.com/pooltogether/etherplex
- Homepage: https://github.com/pooltogether/etherplex#readme
- Issues: https://github.com/pooltogether/etherplex/issues
- npm.io page: https://npm.io/package/@chanceprotocol/etherplex

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2
- [zen-observable-ts](https://npm.io/package/zen-observable-ts.md) ^0.8.20

## Recent versions

- 1.1.5 (latest) — 2023-08-17

## README

# Etherplex

[Ethers.js](https://github.com/ethers-io/ethers.js) + [Multicall](https://github.com/makerdao/multicall)

Batch multiple Ethereum JSON RPC calls into a single RPC call.

Features:

- Uses the Multicall contract when available
- Falls back to individual RPC requests when not available

# Setup

```bash
$ yarn add @chanceprotocol/etherplex
```

# Usage

1. First create a contract wrapper using the `contract` function
2. Chain calls on the contract and pass the results into the `batch` function

```javascript
import { ethers } from 'ethers'
import { batch, contract } from '@chanceprotocol/etherplex'

// Assuming ERC20Abi is an ABI
// Assume the DAI_ADDRESS and USDC_ADDRESS constants are Ethereum addresses

let daiContract = contract('Dai', ERC20Abi, DAI_ADDRESS)

// Alternatively, you can just pass in an ethers.Contract instance
let ethersContract = new ethers.Contract(USDC_ADDRESS, ERC20Abi, provider)
let usdcContract = contract('Usdc', ethersContract)

let results = await batch(
  ethers.getDefaultProvider(),
  daiContract
    .balanceOf(address)
    .totalSupply(),
  usdcContract
    .balanceOf(address)
    .totalSupply()
)
/*
Will yield:

{
  Dai: {
    'balanceOf(address)': [BigNumber],
    balanceOf: [BigNumber],
  },
  Usdc: {
    'balanceOf(address)': [BigNumber],
    balanceOf: [BigNumber],
  }
}

*/
```

---
_Source: https://npm.io/package/@chanceprotocol/etherplex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
