# Ethers.js integration

Ethers.js is a lightweight JavaScript library for interacting with Ethereum and other EVM-compatible blockchains. It is commonly used by developers to build decentralized applications (dApps) and manage Ethereum-based operations like deploying smart contracts, interacting with them, and managing user wallets.

### Install Ethers.js

Add Ethers.js to your project using your preferred package manager:

* npm

```bash
npm install ethers
```

* yarn

```bash
yarn add ethers
```

### Set GetBlock as a provider

```javascript
// Import the Ethers library
const { ethers } = require('ethers');

// Set up the provider (replace ACCESS_TOKEN with your actual token)
const provider = new ethers.JsonRpcProvider('https://go.getblock.io/ACCESS_TOKEN');

//Call a method using the provider
const main = async () => {
  const blockNumber = await provider.getBlockNumber();
  console.log("Latest Block Number:", blockNumber);
};

// Call the main function
main();
```

For further details and advanced usage, explore the [Ethers.js documentation](https://docs.ethers.org/v6/getting-started/).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.getblock.io/guides/using-web3-libraries/ethers.js-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
