Alibaba cloud ant contract experience chain Quick Start

Keywords: Java SDK Netty Windows Blockchain

Summary

Alibaba cloud ant blockchain provides a contract experience chain, which is convenient for users to quickly experience the blockchain, and can quickly test and experience the functions of the blockchain free of charge. The following describes the use of contract experience step by step from three aspects: portal creation and related configuration acquisition, dependency package installation and test code configuration.

Step By Step

1. Service application, portal address

Download the generated certificate and other information when applying for the certificate to the local, and remember the password set when configuring the SSL certificate.

2. Create account


Download user.key to local.

3. All downloaded information

4. Dependent package installation

The sdk is decompressed. Run the following command to install the jar package to the local warehouse under the decompressed path

//Install SDK to local warehouse
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=jar -DpomFile=pom.xml
//The installation of Netty depends on the local warehouse. Pay attention to the selection of the corresponding platform, Netty tcnative OpenSSL static version, and the modification of classifier, MacOS: osx-x86 ʄ, Linux: linux-x86 ʄ, windows: windows-x86 ʄ
mvn install:install-file -Dfile=netty-tcnative-openssl-static-2.0.17-Final-mychain-windows-x86_64.jar -DgroupId=io.netty -DartifactId=netty-tcnative-openssl-static -Dversion=2.0.17-Final-mychain -Dpackaging=jar -Dclassifier=windows-x86_64

5,Code Sample

  • 5.1 demosample.java Download address
  • 5.2 pom.xml
    <dependencies>
        <dependency>
            <groupId>com.alipay.mychainx</groupId>
            <artifactId>mychainx-sdk</artifactId>
            <!--Please use the latest SDK Edition -->
            <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>
  • 5.3 copy related configuration files to the project resources path

  • 5.4 configuration of code related parameters

5.5 Result

create testAccount1 success.
create testAccount2 success.
deploy contract success.
issue success.
transfer success.
check account balance success.

If the project prompts that the method or package cannot be found, you can Update Maven or Reimport it, reload the package and run it again.

Reference link

Trial contract experience chain
Java SDK description
Java SDK quick start

Posted by flashman on Fri, 10 Jan 2020 06:38:44 -0800