Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chainstacklabs/query-evm-nodes-javascript
Switch to retrieving historical data from an archive node when it's not available on the full one
https://github.com/chainstacklabs/query-evm-nodes-javascript
archive erigon ethereum evm geth javascript
Last synced: 3 months ago
JSON representation
Switch to retrieving historical data from an archive node when it's not available on the full one
- Host: GitHub
- URL: https://github.com/chainstacklabs/query-evm-nodes-javascript
- Owner: chainstacklabs
- Created: 2022-07-20T05:49:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-05T06:50:41.000Z (almost 2 years ago)
- Last Synced: 2023-07-24T08:32:59.194Z (over 1 year ago)
- Topics: archive, erigon, ethereum, evm, geth, javascript
- Language: JavaScript
- Homepage: https://chainstack.com/querying-full-and-archive-evm-nodes-with-javascript/
- Size: 96.7 KB
- Stars: 0
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Chainstack is the leading suite of services connecting developers with Web3 infrastructure
• Homepage •
Supported protocols •
Chainstack blog •
Chainstack docs •
Blockchain API reference •
Start for free •# Querying full and archive EVM nodes with JavaScript
This project allows the retrieval of historical data from the blockchain programmatically, switching between a full and archive node provider when necessary.
See the full tutorial on the Chainstack blog:
* [Querying full and archive Ethereum nodes with JavaScript](https://chainstack.com/querying-full-and-archive-evm-nodes-with-javascript/)## Project details
This repository holds the JavaScript version of a tool to query common state functions. Some essential functions include getting an address balance and storage at a given position, a contract bytecode, or even the whole transactions included on a given block.
This tool queries the blockchain using the web3 and inquirer libraries for JavaScript.
## Quick start
### Clone this repository
```sh
git clone https://github.com/yieniggu/chainstack-full-vs-archive-query-js.git
```### Install dependencies
```sh
npm ci
```> Use `npm ci` to launch a `clean install` of the dependencies, this will install the same version as in the `package.json` file.
### edit the .env.sample file
Add your RPC node URLs and rename the file to `.env`.
```env
CHAINSTACK_FULL_NODE="CHAINSTACK_FULL_NODE_URL"
CHAINSTACK_ARCHIVE_NODE="CHAINSTACK_ARCHIVE_NODE_URL"
```### Run the program
```sh
npm run start
```## Prerequisites
* Node.js: ^16.17.0— [install Node](https://nodejs.org/en/download/)
* A full and archive node RPC endpoints.Deploy a full and archive node with Chainstack:
1. [Sign up with Chainstack](https://console.chainstack.com/user/account/create).
1. [Deploy a node](https://docs.chainstack.com/platform/join-a-public-network).
1. [View node access and credentials](https://docs.chainstack.com/platform/view-node-access-and-credentials).## Dependencies
* dotenv: ^16.0.3
* inquirer: ^8.2.4
* web3.js: ^1.7.4## Install
Clone this repository:
```sh
git clone https://github.com/yieniggu/chainstack-full-vs-archive-query-js.git
```Install the dependencies in the project's directory:
```sh
cd query-full-and-archive-nodes-javascript
``````sh
npm ci
```
> Use `npm ci` to launch a `clean install` of the dependencies, this will install the same version as in the `package.json` file.