-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from soos3d/main
standardize
- Loading branch information
Showing
6 changed files
with
238 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CHAINSTACK_FULL_NODE="CHAINSTACK_FULL_NODE_URL" | ||
CHAINSTACK_ARCHIVE_NODE="CHAINSTACK_ARCHIVE_NODE_URL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,120 @@ | ||
node_modules/ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
.env.production | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# End of https://mrkandreev.name/snippets/gitignore-generator/#Node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,102 @@ | ||
# Full vs Archive Node query | ||
<img width="1200" alt="Labs" src="https://user-images.githubusercontent.com/99700157/213291931-5a822628-5b8a-4768-980d-65f324985d32.png"> | ||
|
||
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. | ||
<p> | ||
<h3 align="center">Chainstack is the leading suite of services connecting developers with Web3 infrastructure</h3> | ||
</p> | ||
|
||
For the full walkthrough, see [Querying full and archive Ethereum nodes with JavaScript](https://chainstack.com/querying-full-and-archive-evm-nodes-with-javascript/). | ||
<p align="center"> | ||
<a target="_blank" href="https://chainstack.com/build-better-with-ethereum/"><img src="https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Ethereum.svg" /></a> | ||
<a target="_blank" href="https://chainstack.com/build-better-with-bnb-smart-chain/"><img src="https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/BNB.svg" /></a> | ||
<a target="_blank" href="https://chainstack.com/build-better-with-polygon/"><img src="https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Polygon.svg" /></a> | ||
<a target="_blank" href="https://chainstack.com/build-better-with-avalanche/"><img src="https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Avalanche.svg" /></a> | ||
<a target="_blank" href="https://chainstack.com/build-better-with-fantom/"><img src="https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Fantom.svg" /></a> | ||
</p> | ||
|
||
### Instructions | ||
<p align="center"> | ||
• <a target="_blank" href="https://chainstack.com/">Homepage</a> • | ||
<a target="_blank" href="https://chainstack.com/protocols/">Supported protocols</a> • | ||
<a target="_blank" href="https://chainstack.com/blog/">Chainstack blog</a> • | ||
<a target="_blank" href="https://docs.chainstack.com/quickstart/">Chainstack docs</a> • | ||
<a target="_blank" href="https://docs.chainstack.com/quickstart/">Blockchain API reference</a> • | ||
<a target="_blank" href="https://console.chainstack.com/user/account/create">Start for free</a> • | ||
</p> | ||
|
||
# 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 | ||
``` | ||
git clone https://github.com/yieniggu/chainstack-full-vs-archive-query-js.git | ||
cd chainstack-full-vs-archive-query-js | ||
npm i | ||
node index | ||
|
||
### 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. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters