> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.chainstack.com/feedback

```json
{
  "path": "/reference/ethersjs-chainstackprovider",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Ethers ChainstackProvider Documentation

> Use ethers.js ChainstackProvider to connect to Chainstack nodes via JSON-RPC. Manage wallets, deploy contracts, and interact with Ethereum and EVM chains.

Recently, `ethers.js` has introduced the `ChainstackProvider`, a new addition to its **Community Providers**.

<Info>
  Chainstack provider on the [ethers.js documentation](https://docs.ethers.org/v6/api/providers/thirdparty/#providers-chainstack) .
</Info>

`ChainstackProvider`integrates directly with`ethers.js`, enabling developers to connect seamlessly to multiple blockchain networks supported by Chainstack via JSON-RPC endpoints. The `ChainstackProvider` enhances the development of decentralized applications by offering robust and scalable connections to blockchain networks such as Ethereum Mainnet, Arbitrum, BNB Smart Chain Mainnet, and Polygon.

## Supported Networks

`ChainstackProvider` supports connections to:

* Ethereum Mainnet (mainnet)
* Arbitrum (arbitrum)
* BNB Smart Chain Mainnet (bnb)
* Polygon (matic)

## Class Overview

### ChainstackProvider

The `ChainstackProvider` extends `JsonRpcProvider` and implements the `CommunityResourcable` interface. It allows users to connect to Chainstack’s JSON-RPC endpoints.

This provider is particularly useful for developers needing reliable network access to test and prototype blockchain applications.

<Info>
  A default, highly-throttled node is used by default. Deploy a high performance node and use your authorization key to increase performance.
</Info>

#### Constructor

```javascript JavaScript theme={"system"}
new ChainstackProvider(network?: Networkish, apiKey?: null | string)
```

**Parameters:**

* `network`: Optional. The network identifier.
* `apiKey`: Optional. The authorization key from your deployed Chainstack node.

## Getting Started

To start using the `ChainstackProvider`you must first install `ethers.js`:

```shell Bash theme={"system"}
npm install ethers
```

### Example Usage

Here's an example of creating a `ChainstackProvider` instance and call the `eth_chainId` method:

```javascript ethers.js theme={"system"}
const ethers = require("ethers");

// Create a ChainstackProvider instance for Ethereum mainnet
const chainstack = new ethers.ChainstackProvider("mainnet");

const chainId = async () => {
  // This will return the value in Hex
  const chainId = await chainstack.send("eth_chainId");
  console.log(\`Hex Chain ID: ${chainId}\`);
};

chainId();
```

### API Key Configuration

For better performance and higher rate limits, deploy a node from Chainstack and use its authorization key to instantiate the`ChainstackProvider`.

Follow these steps to sign up on Chainstack, deploy a node, and find your endpoint credentials:

<Steps>
  <Step>
    [Sign up with Chainstack](https://console.chainstack.com/user/account/create).
  </Step>

  <Step>
    [Deploy a node](https://docs.chainstack.com/docs/manage-your-networks).
  </Step>

  <Step>
    [View node access and credentials](https://docs.chainstack.com/docs/manage-your-node#view-node-access-and-credentials).
  </Step>
</Steps>

<Info>
  You must deploy a [Global Node](https://docs.chainstack.com/docs/global-elastic-node) to use the authorization key in `ChainstackProvider`.
</Info>

Once deployed, your node RPC ULR will look like this:

> [https://ethereum-mainnet.core.chainstack.com/AUTH\_KEY](https://ethereum-mainnet.core.chainstack.com/AUTH_KEY)

Now you can add the `AUTH_KEY` to the `ChainstackProvider` instance:

```javascript ethers.js theme={"system"}
const ethers = require("ethers");

// Create a ChainstackProvider instance for Ethereum mainnet
const chainstack = new ethers.ChainstackProvider("mainnet", "AUTH_KEY");
```
