An example web3j application to interact with your Ethereum or Quorum node deployed with Chainstack.
Running the application will:
- Connect to your Ethereum node or Quorum node with basic authentication.
- Run the function ethGetBlockByNumber.
- Print the latest block number.
- Java 1.8+
- Maven
- In
src/main/java/getLatestBlock/App.java, repaceRPC_USERNAME,RPC_PASSWORD, andRPC_ENDPOINTwith your access and credentials. - In the root directory, run
mvn package. This will build the app in thetargetdirectory. - Change to the
targetdirectory and runjava -jar web3j-getLatestBlock-1-jar-with-dependencies.jar.