|
1 |
| -# Full vs Archive Node query |
| 1 | +<img width="1200" alt="Labs" src="https://user-images.githubusercontent.com/99700157/213291931-5a822628-5b8a-4768-980d-65f324985d32.png"> |
2 | 2 |
|
3 |
| -This repository contains the javascript version to query common state functions such as `getBalance()` and custom smart contract functions such as `symbol()` (ERC-20) from a given block in a programmatic way, switching between full and archive nodes when needed. |
| 3 | +> Chainstack is the leading suite of services connecting developers with Web3 infrastructure. |
4 | 4 |
|
5 |
| -For the full walkthrough, see [Querying full and archive Ethereum nodes with JavaScript](https://chainstack.com/querying-full-and-archive-evm-nodes-with-javascript/). |
| 5 | +<p align="center"> |
| 6 | + <a target="_blank" href="https://chainstack.com/build-better-with-ethereum/"><img src="https://img.shields.io/badge/Ethereum-3C3C3D?style=for-the-badge&logo=Ethereum&logoColor=white" /></a> |
| 7 | + <a target="_blank" href="https://chainstack.com/build-better-with-bnb-smart-chain/"><img src="https://tinyurl.com/mp2wu3xx" /></a> |
| 8 | +</p> |
6 | 9 |
|
7 |
| -### Instructions |
| 10 | +<p align="center"> |
| 11 | + • <a target="_blank" href="https://chainstack.com/">Homepage</a> • |
| 12 | + <a target="_blank" href="https://chainstack.com/protocols/">Supported protocols</a> • |
| 13 | + <a target="_blank" href="https://chainstack.com/blog/">Chainstack blog</a> • |
| 14 | + <a target="_blank" href="https://docs.chainstack.com/quickstart/">Chainstack docs</a> • |
| 15 | + <a target="_blank" href="https://docs.chainstack.com/quickstart/">Blockchain API reference</a> • |
| 16 | + <a target="_blank" href="https://console.chainstack.com/user/account/create">Start for free</a> • |
| 17 | +</p> |
8 | 18 |
|
| 19 | +# Querying full and archive EVM nodes with JavaScript |
| 20 | + |
| 21 | +This project allows the retrieval of historical data from the blockchain programmatically, switching between a full and archive node provider when necessary. |
| 22 | + |
| 23 | +See the full tutorial on the Chainstack blog: |
| 24 | +* [Querying full and archive Ethereum nodes with JavaScript](https://chainstack.com/querying-full-and-archive-evm-nodes-with-javascript/) |
| 25 | + |
| 26 | +## Project details |
| 27 | + |
| 28 | +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. |
| 29 | + |
| 30 | +This tool queries the blockchain using the web3 and inquirer libraries for JavaScript. |
| 31 | + |
| 32 | +## Quick start |
| 33 | + |
| 34 | +### Clone this repository |
| 35 | + |
| 36 | +```sh |
| 37 | +git clone https://github.com/yieniggu/chainstack-full-vs-archive-query-js.git |
9 | 38 | ```
|
10 |
| - git clone https://github.com/yieniggu/chainstack-full-vs-archive-query-js.git |
11 |
| - cd chainstack-full-vs-archive-query-js |
12 |
| - npm i |
13 |
| - node index |
| 39 | + |
| 40 | +### Install dependencies |
| 41 | + |
| 42 | +```sh |
| 43 | +npm ci |
| 44 | +``` |
| 45 | + |
| 46 | +> Use `npm ci` to launch a `clean install` of the dependencies, this will install the same version as in the `package.json` file. |
| 47 | +
|
| 48 | +### edit the .env.sample file |
| 49 | + |
| 50 | +Add your RPC node URLs and rename the file to `.env`. |
| 51 | + |
| 52 | +```env |
| 53 | +CHAINSTACK_FULL_NODE="CHAINSTACK_FULL_NODE_URL" |
| 54 | +CHAINSTACK_ARCHIVE_NODE="CHAINSTACK_ARCHIVE_NODE_URL" |
| 55 | +``` |
| 56 | + |
| 57 | +### Run the program |
| 58 | + |
| 59 | +```sh |
| 60 | +npm run start |
| 61 | +``` |
| 62 | + |
| 63 | +## Prerequisites |
| 64 | + |
| 65 | +* Node.js: ^16.17.0— [install Node](https://nodejs.org/en/download/) |
| 66 | +* A full and archive node RPC endpoints. |
| 67 | + |
| 68 | +Deploy a full and archive node with Chainstack: |
| 69 | + |
| 70 | +1. [Sign up with Chainstack](https://console.chainstack.com/user/account/create). |
| 71 | +1. [Deploy a node](https://docs.chainstack.com/platform/join-a-public-network). |
| 72 | +1. [View node access and credentials](https://docs.chainstack.com/platform/view-node-access-and-credentials). |
| 73 | + |
| 74 | +## Dependencies |
| 75 | + |
| 76 | +* dotenv: ^16.0.3 |
| 77 | +* inquirer: ^8.2.4 |
| 78 | +* web3.js: ^1.7.4 |
| 79 | + |
| 80 | +## Install |
| 81 | + |
| 82 | +Clone this repository: |
| 83 | + |
| 84 | +```sh |
| 85 | +git clone https://github.com/yieniggu/chainstack-full-vs-archive-query-js.git |
| 86 | +``` |
| 87 | + |
| 88 | +Install the dependencies in the project's directory: |
| 89 | + |
| 90 | +```sh |
| 91 | +cd query-full-and-archive-nodes-javascript |
| 92 | +``` |
| 93 | + |
| 94 | +```sh |
| 95 | +npm ci |
14 | 96 | ```
|
| 97 | +> Use `npm ci` to launch a `clean install` of the dependencies, this will install the same version as in the `package.json` file. |
0 commit comments