# @acala-network/eth-providers

Latest version **2.10.0** (published 2025-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @acala-network/eth-providers
pnpm add @acala-network/eth-providers
yarn add @acala-network/eth-providers
bun add @acala-network/eth-providers
```

## Health

**Score 60/100 (C)** — status: stable.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.10.0 |
| Published | 2025-10-02 |
| First published | 2021-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 484.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Acala Developers <hello@acala.network> |
| Maintainers | xlc, aniiantt, qwer951123, shunjizhan |

## Links

- npm: https://www.npmjs.com/package/@acala-network/eth-providers
- npm.io page: https://npm.io/package/@acala-network/eth-providers

## Dependencies (7)

- [bn.js](https://npm.io/package/bn.js.md) ~5.2.1
- [ethers](https://npm.io/package/ethers.md) ~5.7.0
- [graphql](https://npm.io/package/graphql.md) ~16.0.1
- [lru-cache](https://npm.io/package/lru-cache.md) ~7.8.2
- [graphql-request](https://npm.io/package/graphql-request.md) ~3.6.1
- [@acala-network/contracts](https://npm.io/package/@acala-network/contracts.md) 4.3.4
- [@acala-network/eth-transactions](https://npm.io/package/@acala-network/eth-transactions.md) 2.10.0

## Recent versions

- 2.10.0 (latest) — 2025-10-02
- 2.7.5-1 (beta) — 2023-07-27
- 2.9.9 — 2025-09-25
- 2.9.8 — 2025-08-27
- 2.9.7 — 2025-08-19
- 2.9.6 — 2025-05-15
- 2.9.5 — 2024-11-29
- 2.9.4 — 2024-11-14
- 2.9.3 — 2024-11-14
- 2.9.2 — 2024-11-13
- 2.9.1 — 2024-11-06
- 2.9.0 — 2024-11-06
- 2.8.10 — 2024-10-24
- 2.8.9 — 2024-08-23
- 2.8.8 — 2024-08-20
- … 117 more at https://npm.io/package/@acala-network/eth-providers/versions

## README

# @acala-network/eth-providers
This package includes two providers, and both of their APIs are mostly compatible with ethers.js [JsonRpcProvider](https://docs.ethers.io/v5/single-page/#/v5/api/providers/jsonrpc-provider/-%23-JsonRpcProvider).

 - **AcalaJsonRpcProvider**: used as a drop-in replacement for `ethers.JsonRpcProvider` to interact with EVM+ via [ETH JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/).
 - **EvmRpcProvider**: used internally by [eth-rpc-adapter](../eth-rpc-adapter). It connects to a node via substrate node url, instead of eth json-rpc.

In many cases using `ethers.JsonRpcProvider` also works with EVM+, in particularly all **read operations**, such as getting receipts, logs, block data, etc. However, we can't use it to **send transactions**, which will throw `tx hash not match` error. In such case we can use `AcalaJsonRpcProvider` instead.

## Getting Started
### install
```
yarn add @acala-network/eth-providers
# or 
npm install @acala-network/eth-providers
```

### create a provider instance 
- **AcalaJsonRpcProvider**

`AcalaJsonRpcProvider` matches all APIs of `ethers.JsonRpcProvider`, so you can use it as a drop-in replacement, and interact with EVM+ via ETH RPC. **This is the preferred way**.
```ts
import { AcalaJsonRpcProvider } from "@acala-network/eth-providers";

// https://evmdocs.acala.network/network/network-configuration#karura-mainnet
const KARURA_ETH_RPC= 'https://eth-rpc-karura.aca-api.network';

const provider = new AcalaJsonRpcProvider(KARURA_ETH_RPC);
```

- **EvmRpcProvider**

If you wish to communicate with EVM+ by websocket and substrate node url, instead of via ETH RPC, you can do this by using `EvmRpcProvider`.
```ts
import { EvmRpcProvider } from "@acala-network/eth-providers";

const KARURA_NODE_URL = 'wss://karura-rpc.aca-api.network';
const KARURA_SUBQL_URL = 'https://subql-query-karura.aca-api.network';

const provider = new EvmRpcProvider(
  KARURA_NODE_URL,
  { subqlUrl: KARURA_SUBQL_URL },
);
await provider.isReady();
```

### use the provider
You can use the provider similar to how you will use `ethers.JsonRpcProvider`

```ts
// get some info
const chainId = await provider.chainId();
const curBlock = await provider.getBlockNumber();
const balance = await provider.getBalance('0x1c3D657F0518A094BF351852bad4285EFc0D5Ce9');
const blockData = await provider.getBlockData('latest', false);

// send transaction
const wallet = new Wallet(PRIVATE_KEY, provider);
const contractInstance = new Contract(CONTRACT_ADDR, CONTRACT_ABI, wallet);
await contractInstance.someMethod();
```

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