Introduction to Java SDK
15

Getting Started

The Java SDK requires at a minimum Java 8.

The source code for the Java SDK can be found at https://github.com/enjin/enjin-java-sdk.

Java Docs

Downloading the SDK

Maven

XML
<dependency>
 <groupId>com.enjin</groupId>
 <artifactId>blockchain-sdk</artifactId>
 <version>1.0.1</version>
</dependency>

Gradle

Groovy
dependencies {
   implementation 'com.enjin:blockchain-sdk:1.0.1'
}

Git

For those that don't use Maven or Gradle, you can manually build the Java SDK and add it to your projects classpath.

  1. Clone the Java SDK repository using git.
  2. Initialize git modules: <inline-code>git submodule init<inline-code>
  3. Build the Java SDK: "./gradlew sdk:build" (Linux) or "./gradlew.bat sdk:build" (Windows).
  4. Navigate to the <inline-code>build/libs<inline-code> folder in the sdk module.
  5. Add the jar ending in <inline-code>-all<inline-code> to your projects classpath.

Setup and Run SDK Example

Create Example Project

  1. Register if you have not done so already.
  2. Select <inline-code>Create Project<inline-code> from the <inline-code>Platform<inline-code> page.
  3. Give the project a name and description. The image is optional.
  4. Click <inline-code>Save Change<inline-code>s to create the project.

Create Example Assets

  1. Open your project by selecting it from the <inline-code>Platform<inline-code> page.
  2. Go to <inline-code>Assets<inline-code> and click <inline-code>Create Asset<inline-code>.
  3. Set the name, total supply, value per asset, ENJ returned on melt, and the starting supply. All other settings can be left as the default.
  4. Click <inline-code>Create Asset<inline-code>.

Configuring the Example

Next we need the required details to use for our project. You will need the ID of the identity linked to your wallet, the ID and secret of the project you created, and the IDs of the assets you created.

Getting the Project ID and Secret

To get the ID and secret of the project you created you can go here and execute the following query:

GraphQL
query {
 EnjinUser {
   apps {
     id
     name
     secret
   }
 }
}
Getting the Developer Identity ID

The following query can be used to get the ID of the developer identity associated with your project:

GraphQL
query {
 EnjinUser {
   identities {
     id
     appId
     wallet {
       ethAddress
     }
   }
 }
}
Getting the Asset IDs

You can find the IDs of the assets you created by going to the assets tab of your project. The IDs are under the <inline-code>Item ID<inline-code> column.

Previous
next
On This Page