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_ENDPOINT
with your access and credentials. - In the root directory, run
mvn package
. This will build the app in thetarget
directory. - Change to the
target
directory and runjava -jar web3j-getLatestBlock-1-jar-with-dependencies.jar
.