ethers.js
has introduced the ChainstackProvider
, a new addition to its Community Providers.
Chainstack provider on the ethers.js documentation .
ChainstackProvider
integrates directly withethers.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
TheChainstackProvider
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.
A default, highly-throttled node is used by default. Deploy a high performance node and use your authorization key to increase performance.
Constructor
JavaScript
network
: Optional. The network identifier.apiKey
: Optional. The authorization key from your deployed Chainstack node.
Getting Started
To start using theChainstackProvider
you must first install ethers.js
:
Bash
Example Usage
Here’s an example of creating aChainstackProvider
instance and call the eth_chainId
method:
ethers.js
API Key Configuration
For better performance and higher rate limits, deploy a node from Chainstack and use its authorization key to instantiate theChainstackProvider
.
Follow these steps to sign up on Chainstack, deploy a node, and find your endpoint credentials:
You must deploy a Global Node to use the authorization key in
ChainstackProvider
.https://ethereum-mainnet.core.chainstack.com/AUTH_KEYNow you can add the
AUTH_KEY
to the ChainstackProvider
instance:
ethers.js