Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 1015 Bytes

File metadata and controls

20 lines (13 loc) · 1015 Bytes

web3j example to get the latest block on Ethereum or Quorum

An example web3j application to interact with your Ethereum or Quorum node deployed with Chainstack.

Running the application will:

  1. Connect to your Ethereum node or Quorum node with basic authentication.
  2. Run the function ethGetBlockByNumber.
  3. Print the latest block number.

Requirements

  1. Java 1.8+
  2. Maven

Steps

  1. In src/main/java/getLatestBlock/App.java, repace RPC_USERNAME, RPC_PASSWORD, and RPC_ENDPOINT with your access and credentials.
  2. In the root directory, run mvn package. This will build the app in the target directory.
  3. Change to the target directory and run java -jar web3j-getLatestBlock-1-jar-with-dependencies.jar.