Giter Site home page Giter Site logo

geth-web3-tools's Introduction

geth-web3-tools

get_block.js can only be run in parallel to running geth node. To learn how to run a node please visit: https://geth.ethereum.org/docs/getting-started. Running an ethereum node allows direct access to the bolckchain. Note: running a node even in snap (default) mode requires sufficient computational resources. Please consult ethereum.org for more details.

Once an ethereum node is synced in preferred mode (snap mode is sufficient), install nodejs following instructions here: https://nodejs.org/en/download/

get_block.js: computes EIP-1559 next block's base fee

The script connects to locally running node using "geth.ipc" located in your .ethereum folder which is generated at the directory where geth is running. You need to locate the file and replace "path_to_the_file" with the relevant directory path.

To run code: node get_block.js

The code computes expected base fee (as proposed for EIP-1559) for the upcoming block and prints out:

  • parent block (most recently confirmed block)
  • parent block's base fee
  • parent block's gas used
  • parent block's gas limit
  • computed expected base fee for the upcoming block

get_contractABI.js (using Etherscan.org API): used to get access to public variables of a smart contract

To access smart contract's on EVM, a contract ABI (Application Binary Interface) must be supplied to web3 nodejs library's contract method. The code demonstrates how an ABI can be obtained from Etherescan.org for a supplied smart contract address. This requires Etherscan API token, which can be obtained (free API is sufficient plan) following instructions here: https://etherscan.io/apis.

Why would you want to get access to smart contracts? Such an access would provide means to get public variables of a smart contract. For instance, if you would like to know current price of Ethereum, you would get reserves data from ETH-USDC smart contract and compute current pricing of the assets.

geth-web3-tools's People

Contributors

gaziz86 avatar

Watchers

 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.