The Java SDK for the Ant Blockchain contract platform lets you submit transactions, query transaction receipts, and subscribe to events on a standard contract blockchain. The SDK covers five service areas: account, contract, event, query, and local services. The SDK supports both synchronous and asynchronous call patterns.
Prerequisites
Before you begin, make sure you have:
Java Development Kit (JDK) 7 or later — run
java -versionto checkMaven 3.5.4 or later — run
mvn -vto check
Release notes
Java SDK versions
| Version | Supported blockchain | What's included | Download |
|---|---|---|---|
| 0.10.2.6 | Standard contract blockchains | All client features of the contract platform | Download SDK |
OS-specific Netty packages
The SDK's .jar package depends on a Netty native library. Because Netty ships platform-specific binaries, you need to download the correct package for your operating system. All three packages are bundled with the Java SDK download from the BaaS console management page.
Note: Download the Java SDK from the management page in the BaaS console. The Netty packages listed below are included in that download.
| File | OS | Download |
|---|---|---|
netty-tcnative-openssl-static-2.0.17-Final-mychain-linux-x86_64.jar | Linux | Download |
netty-tcnative-openssl-static-2.0.17-Final-mychain-windows-x86_64.jar | Windows | Download |
netty-tcnative-openssl-static-2.0.17-Final-mychain-osx-x86_64.jar | macOS | Download |
Install the SDK with Maven
Because the SDK is not published to Maven Central, install it into your local repository before declaring it as a dependency.
In your terminal, go to the root directory of the downloaded SDK files.
Install the SDK
.jarinto the local repository:mvn install:install-file \ -Dfile=mychainx-sdk-0.10.2.6.jar \ -DgroupId=com.alipay.mychainx \ -DartifactId=mychainx-sdk \ -Dversion=0.10.2.6 \ -Dpackaging=jarInstall the Netty package for your operating system. Set the
-Dclassifiervalue to match your OS:OS Classifier value macOS osx-x86_64Linux linux-x86_64Windows windows-x86_64The following example installs the macOS package:
mvn install:install-file \ -Dfile=netty-tcnative-openssl-static-2.0.17-Final-mychain-osx-x86_64.jar \ -DgroupId=io.netty \ -DartifactId=netty-tcnative-openssl-static \ -Dversion=2.0.17-Final-mychain \ -Dpackaging=jar \ -Dclassifier=osx-x86_64Add the SDK dependency and the
os-maven-pluginbuild extension to yourpom.xml. The plugin detects the current OS at build time and selects the correct Netty classifier automatically:<dependencies> <dependency> <groupId>com.alipay.mychainx</groupId> <artifactId>mychainx-sdk</artifactId> <version>0.10.2.6</version> </dependency> </dependencies> <build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.6.1</version> </extension> </extensions> </build>