Simple client for Multichain Platform.
This is a simple client using ApacheHttp4 library for getting responses from a multichain platform. All responses from chain are comming as String.
Necessary dependencies are Apache Http Client and Google GSON library.
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
You can invoke RPC on the chain and get responses. You need four things for invoking the chain:
- the API command
- the parameters (optional, could be null)
- a unique ID (automatically generated by Java using UUID)
- the name of the chain
MultichainApiCommand getinfo = MultichainApiCommand.prepareCall("getinfo", null, UUID.randomUUID(), MultichainConfig.CHAIN_NAME);
String[] params = new String[] {"root"};
MultichainApiCommand getstreaminfo = MultichainApiCommand.prepareCall("getstreaminfo", params, UUID.randomUUID(), MultichainConfig.CHAIN_NAME);