Skip to main content
Version: IOTA

Connecting to Node(s)

You can access all the features of the library using an instance of the Client class. The Client class provides high-level abstraction to all interactions over IOTA network (Tangle). You have to instantiate this class before you start any interactions with the library, or more precisely with the IOTA nodes that power IOTA network.

The library is designed to automatically choose a starting IOTA node based on the network type you would like to participate in: devnet or mainnet.

Password Storage

It is not recommended to store passwords or seeds on a host's environment variables or in the source code in a production setup. Please follow our backup and security recommendations for production use.

public static void nodeInfo() {
try {
Client iota = node();

System.out.println("Node healthy: " + iota.getHealth());

NodeInfoWrapper info = iota.getInfo();
System.out.println("Node url: " + info.url());
System.out.println("Node Info: " + info.nodeInfo());
} catch (ClientException e) {
System.out.println("Error: " + e.getMessage());

Output example of the getInfo() function of the Client instance:

Load Balancers & Health Checks

If you use node load balancers then the health check may be useless as the follow-up API calls may be served by a different node behind the load balancer that may not have been checked. You should be aware of this fact and trust that the load balancer participates only with nodes that are in healthy state. The library additionally supports a management of internal node pool, so you can mimic a load-balancer-like behavior using this feature locally.

You can instantiate the Client, and optionally configure it, by chaining calls to the ClientBuilder helper class. The ClientBuilder helper class provides several chaining calls through which the process can be closely managed.

The most common ones are:

  • .withNetwork(string): Can be either devnet or mainnet. It instructs the library whether to automatically select devnet nodes or mainnet nodes.
  • .withNode(string): Specify address of actual running IOTA node that should be used to communicate with in the format https://node:port). For example:
  • .withNodePoolUrls(String[]): The library also supports managing a pool of nodes. You can provide a list of nodes and the library manages the access to them automatically by selecting them based on their sync status. If you provide .withNodePoolUrls(String[]), then the library periodically will periodically check whether node is in sync or not by calling .withNodeSyncInterval(float).
  • .withLocalPow(boolean): If .localPow (True) a Proof-of-work will be done locally and not remotely.
  • .withNodeSyncDisabled(): When called, the library will use nodes that are not in sync with network. This parameter is usually useful if you would like to interact with a local test node that is not fully synced. This parameter should not be used in production.