Skip to content

Latest commit

 

History

History
124 lines (102 loc) · 8.04 KB

README.md

File metadata and controls

124 lines (102 loc) · 8.04 KB

Java examples

SDK

Transactions

Schedule Transaction

Accounts and HBAR

Consensus Service

Token Service

File Service

Smart Contract Service

Miscellaneous

Usage

Configuration

Running the examples requires .env file to exist in the examples folder if running with Gradle:

cp .env.sample .env

And in the root project folder if running with Intellij IDEA:

cp .env.sample ../.env

The OPERATOR_ID and OPERATOR_KEY variables should be set in a .env file. Optionally, you can set the HEDERA_NETWORK and SDK_LOG_LEVEL variables:

  • You can set the HEDERA_NETWORK to localhost, testnet, previewnet or mainnet for configuring the network. If the HEDERA_NETWORK is not set, it will default to testnet.
  • You can set the SDK_LOG_LEVEL to TRACE, DEBUG, INFO, WARN, ERROR or SILENT for configuring the logging. If the SDK_LOG_LEVEL is not set, it will default to SILENT. Important pre-requisite to see logs: set simple logger log level to same level as the SDK_LOG_LEVEL, for example via VM options: -Dorg.slf4j.simpleLogger.log.com.hedera.hashgraph=trace.

Therefore, the format of the configuration file should be as follows:

OPERATOR_ID=0.0.102...
OPERATOR_KEY=0xeae...
# Optionally set HEDERA_NETWORK and SDK_LOG_LEVEL
HEDERA_NETWORK=previewnet
SDK_LOG_LEVEL=WARN

Running with Gradle

Note that the below ./gradlew commands should be run from the root of the project.

Template:

./gradlew -q :examples:run<NameOfExample>

Concrete example:

./gradlew -q :examples:runGenerateKey

Running with Intellij

Simply execute the main function of the desired example.