Coder Social home page Coder Social logo

thaingo / hedera-sdk-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashgraph/hedera-sdk-java

0.0 1.0 0.0 68.8 MB

Hedera™ Hashgraph SDK for Java

Home Page: https://docs.hedera.com/guides/docs/sdks

License: Apache License 2.0

Java 100.00%

hedera-sdk-java's Introduction

Hedera™ Hashgraph Java SDK

The Java SDK for interacting with Hedera Hashgraph: the official distributed consensus platform built using the hashgraph consensus algorithm for fast, fair and secure transactions. Hedera enables and empowers developers to build an entirely new class of decentralized applications.

Install

NOTE: v1 of the SDK is deprecated and support will be discontinued after October 2021. Please install the latest version 2.0.x or migrate from v1 to the latest 2.0.x version. You can reference the migration documentation here.

Gradle

Select one of the following depending on your target platform.

// Android, Corda DJVM, Java 7+
implementation 'com.hedera.hashgraph:sdk-jdk7:2.0.8'

// Java 9+, Kotlin
implementation 'com.hedera.hashgraph:sdk:2.0.8'

Select one of the following to provide the gRPC implementation.

// netty transport (for high throughput applications)
implementation 'io.grpc:grpc-netty-shaded:1.38.0'

// netty transport, unshaded (if you have a matching Netty dependency already)
implementation 'io.grpc:grpc-netty:1.38.0'

// okhttp transport (for lighter-weight applications or Android)
implementation 'io.grpc:grpc-okhttp:1.38.0'

Select one of the following to enable or disable Simple Logging Facade for Java (SLFJ4).

// Enable logs
implementation 'org.slf4j:slf4j-simple:1.7.29'

// Disable logs
implementation 'org.slf4j:slf4j-nop:1.7.29'

Maven

Select one of the following depending on your target platform.

<!-- Android, Corda DJVM, Java 7+ -->
<dependency>
  <groupId>com.hedera.hashgraph</groupId>
  <artifactId>sdk-jdk7</artifactId>
  <version>2.0.8</version>
</dependency>

<!-- Java 9+, Kotlin -->
<dependency>
  <groupId>com.hedera.hashgraph</groupId>
  <artifactId>sdk</artifactId>
  <version>2.0.8</version>
</dependency>

Select one of the following to provide the gRPC implementation.

<!-- netty transport (for server or desktop applications) -->
<dependency>
  <groupId>io.grpc</groupId>
  <artifactId>grpc-netty-shaded</artifactId>
  <version>1.38.0</version>
</dependency>

<!-- netty transport, unshaded (if you have a matching Netty dependency already) -->
<dependency>
  <groupId>io.grpc</groupId>
  <artifactId>grpc-netty</artifactId>
  <version>1.38.0</version>
</dependency>

<!-- okhttp transport (for lighter-weight applications or Android) -->
<dependency>
  <groupId>io.grpc</groupId>
  <artifactId>grpc-okhttp</artifactId>
  <version>1.38.0</version>
</dependency>

Usage

Examples of several potential use cases and workflows are available within the repository in examples/.

Development

Dependencies

Compile

$ ./gradlew compileJava

Unit Test

$ ./gradlew test

Integration Test

The easiest way to run integration tests is by providing network and operator information in a configuration file. This configuration file is passed into system properties.

$ ./gradlew integrationTest -PCONFIG_FILE="<ConfigurationFilePath>"

An example configuration file can be found in the repo here:

sdk/src/test/resources/client-config-with-operator.json

The format of the configuration file should be as follows:

{
    "network": {
        "<NodeAddress>": "<NodeAccountId>",
        ...
    },
    "operator": {
        "accountId": "<shard.realm.num>",
        "privateKey": "<PrivateKey>"
    }
}

If a configuration file is not provided, OPERATOR_ID and OPERATOR_KEY must be passed into system properties and integration tests will run against the Hedera test network.

$ ./gradlew integrationTest -POPERATOR_ID="<shard.realm.num>" -POPERATOR_KEY="<PrivateKey>"

HEDERA_NETWORK can optionally be used to use previewnet. This System Property can only be set to previewnet.

$ ./gradlew integrationTest -POPERATOR_ID="<shard.realm.num>" -POPERATOR_KEY="<PrivateKey>" -PHEDERA_NETWORK="previewnet"

Note: It is also possible to use a custom network in a configuration file and pass OPERATOR_ID and OPERATOR_KEY into system properties.

An example configuration file containing only network information can be found in the repo here:

sdk/src/test/resources/client-config.json

Examples

Requires OPERATOR_ID and OPERATOR_KEY to be in a .env file in the examples directory. Many examples run against the Hedera test network.

$ ./gradlew -q example:run<NameOfExample>
$ ./gradlew -q example:runGenerateKey

Contributing to this Project

We welcome participation from all developers! For instructions on how to contribute to this repo, please review the Contributing Guide.

License Information

Licensed under Apache License, Version 2.0 – see LICENSE in this repo or apache.org/licenses/LICENSE-2.0.

hedera-sdk-java's People

Contributors

janaakhterov avatar mehcode avatar sheng-long avatar andrix10 avatar sean-tedrow-lb avatar questofiranon avatar simihunjan avatar qtbeee avatar steven-sheehy avatar regan-koopmans avatar timmolter avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.