All Products
Search
Document Center

Blockchain as a Service:Java SDK introduction

Last Updated:Jun 29, 2023

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.

V2.19.1

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 -von 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:

// Install the SDK to the local repository.
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

// 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.
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.

<dependencies>
    <dependency>
        <groupId>com.alipay.mychainx</groupId>
        <artifactId>mychainx-sdk</artifactId>
        <!-- Use the latest SDK version. -->
        <version>0.10.2.12</version>
    </dependency>
  <dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcpkix-jdk15on</artifactId>
    <version>1.60</version>
</dependency>
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.29.Final</version>
</dependency>
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-tcnative-boringssl-static</artifactId>
    <version>2.0.17.Final</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.25</version>
</dependency>
  <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.6</version>
  </dependency>
  <dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.83</version>
  </dependency>
  <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>20.0</version>
  </dependency>
  <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-collections4</artifactId>
      <version>4.2</version>
  </dependency>
  <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.5</version>
  </dependency>
</dependencies>