The last thing to consider is adding a textual or a graphical menu to this application to help the user make their choices. To avoid bloating the project with irrelevant code to our purpose, I have opted for a simple text-based menu:
input = new Scanner(System.in);
CFutures CFutureInstance = null;
System.out.println("Please make your choice:");
System.out.println("1 – Deploy New Cfutures contract.");
System.out.println("2 – Load contract");
System.out.println("3 – Make deposit");
System.out.println("4 – current Fuel price");
System.out.println("5 – Update Fuel price");
System.out.println("6 – Investment offset");
System.out.println("0 - exit");
int selection;
choice: while(input.hasNextInt()) {
selection = input.nextInt();
switch (selection) {
case 0:
break choice;
…
}
}
Great, now run your APP.java file to check whether everything is working as expected. You should see message logs detailing the execution steps, similar to the following:
You might get the event results in arbitrary order, as they are executed asynchronously in parallel and their results are later captured. Therefore, it would be preferable to use a CompletableFuture class to wrap your web3j methods and handle these asynchronous calls.