Giter Site home page Giter Site logo

eth-nodejs's Introduction

eth-nodejs ๐Ÿ“

A Node.js + TypeScript + Viem project to quickly buuild web3 scripts

Abstract

A Node.js template to quickly build script for EVM chains. The template is already setup with basic functionalities (TypeScript implementation, JSON BigInt support... etc).

Functionalites โœจ

  • TypeScript native
  • JSON BigInt support

Packages ๐Ÿ“ฆ

  • viem
  • cli-progress
  • cli-table3
  • commander
  • jest

Setup

# Install packages
bun i

# Set env var
cp .example.env .env

# Then set your own env var in your freshly created .env file
# RPC_URL_ETH => Etehreum RPC url
# WALLET_PRIVATE_KEY => Private key of the wallet used to call the swapToVariable method

Commands

Here are two examples of functions that have already been implemented:

get-balance

Display the ETH balance of an address

  • command name: get-balance
  • arguments
    • address: the address of the balance to fetch
  • options
    • -b (--blockNumber): the blockNumber snapshot to fetch the balance. โš ๏ธ RPC should be an archive node.

Example:

bun run get-balance 0x4801eB5a2A6E2D04F019098364878c70a05158F1 -b 19000000

This will fetch the ETH balance of 0x4801eB5a2A6E2D04F019098364878c70a05158F1 at the block 19000000

get-tokens-holders

Display token holders with their corresponding balance

  • command name: get-tokens-holders
  • arguments
    • tokenAddress: the token address
    • tokenName: token name
    • tokenDeploymentBlock: deployment block number of the token
  • options
    • -b (--blockNumber): the blockNumber snapshot to fetch the holders. โš ๏ธ RPC should be an archive node.
    • -p (--progressBar): display a progress bar

Example:

bun run get-token-holders 0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f GHO 17698470 -b 17699270

This will fetch the all the holders of GHO with their corresponding balance at the block 17699270 (800 block after the token deployment)

Tests

# run tests with bun
bun run test

eth-nodejs's People

Contributors

martingbz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.