All Products
Search
Document Center

Java SDK introduction

Last Updated: Jul 13, 2020

The Java SDK of the Ant blockchain contract platform provides external features as services, including the Account Service, Contract Service, Event Service, Query Service, and Local Service. The SDK provides APIs for synchronously or asynchronously sending and querying for transactions and subscribing to events. Regardless of whether a transaction is sent synchronously or asynchronously, the SDK encapsulates the logic for querying for the receipt after the transaction is sent so that you can view the transaction execution result.

The JAR package of the Java SDK depends on Netty. Different operating systems require that different Netty dependency packages be configured in the Maven file.

Java SDK version

Version Feature update Blockchain version Download link
0.10.2.12 - ABI feature for SDK-side contracts, a global switch for querying for the receipt after a transaction is sent, and transaction receipt queries by block number.
- New reliable message listening mechanism to verify the value range when a method similar to addInt8 is added for a WASM contract, new API for updating the certificate cancellation list, and the hot certificate cancellation feature.
V0.10.2.12.5
V0.10.2.9.3
V0.10.2.9.2
V0.10.2.9.1
V0.10.2.7.1
Click to download the SDK

Netty dependency package

File Description Download link
netty-tcnative-openssl-static-2.0.17-Final-mychain-all.jar The runtime library on which the SDK depends in CentOS, MacOS, or Windows x64, which supports the K1 curve and RSA. Click to download the Netty dependency package

Runtime environment

  • JDK 7 and later versions:Run java -version on the client to check the current Java version.

  • Maven 3.5.4 and later versions:Run mvn -v on the client to check the current Maven version.

  • If you use the SDK in Linux, the glibc version must be later than 2.14.

Introduce the SDK package into the Maven file

  1. Install the downloaded JAR package to the local repository.
  2. Access the root directory of the downloaded file from the command line interface and run the following command:
  1. // Install the SDK to the local repository.
  2. mvn install:install-file -Dfile=mychainx-sdk-0.10.2.12.jar -DgroupId=com.alipay.mychainx -DartifactId=mychainx-sdk -Dversion=0.10.2.12 -Dpackaging=jar -DpomFile=pom.xml
  3. // To use K1, install the Netty dependency package to the local repository. Select the netty-tcnative-openssl-static version for the operating system and modify the classifier, which is osx-x86_64 for macOS, linux-x86_64 for Linux, and windows-x86_64 for Windows.
  4. mvn install:install-file -Dfile=netty-tcnative-openssl-static-2.0.17-Final-mychain-all.jar -DgroupId=io.netty -DartifactId=netty-tcnative-openssl-static -Dversion=2.0.17-Final-mychain-all -Dpackaging=jar

Note: The following Netty version is required.

  1. <dependencies>
  2. <dependency>
  3. <groupId>com.alipay.mychainx</groupId>
  4. <artifactId>mychainx-sdk</artifactId>
  5. <!-- Use the latest SDK version. -->
  6. <version>0.10.2.12</version>
  7. </dependency>
  8. <dependency>
  9. <groupId>org.bouncycastle</groupId>
  10. <artifactId>bcpkix-jdk15on</artifactId>
  11. <version>1.60</version>
  12. </dependency>
  13. <dependency>
  14. <groupId>io.netty</groupId>
  15. <artifactId>netty-all</artifactId>
  16. <version>4.1.29.Final</version>
  17. </dependency>
  18. <dependency>
  19. <groupId>io.netty</groupId>
  20. <artifactId>netty-tcnative-boringssl-static</artifactId>
  21. <version>2.0.17.Final</version>
  22. </dependency>
  23. <dependency>
  24. <groupId>org.slf4j</groupId>
  25. <artifactId>slf4j-api</artifactId>
  26. <version>1.7.25</version>
  27. </dependency>
  28. <dependency>
  29. <groupId>commons-io</groupId>
  30. <artifactId>commons-io</artifactId>
  31. <version>2.6</version>
  32. </dependency>
  33. <dependency>
  34. <groupId>com.alibaba</groupId>
  35. <artifactId>fastjson</artifactId>
  36. <version>1.2.60</version>
  37. </dependency>
  38. <dependency>
  39. <groupId>com.google.guava</groupId>
  40. <artifactId>guava</artifactId>
  41. <version>20.0</version>
  42. </dependency>
  43. <dependency>
  44. <groupId>org.apache.commons</groupId>
  45. <artifactId>commons-collections4</artifactId>
  46. <version>4.2</version>
  47. </dependency>
  48. <dependency>
  49. <groupId>org.apache.commons</groupId>
  50. <artifactId>commons-lang3</artifactId>
  51. <version>3.5</version>
  52. </dependency>
  53. </dependencies>