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.
- Clone the Java SDK repository using git.
- Initialize git modules: <inline-code>git submodule init<inline-code>
- Build the Java SDK: "./gradlew sdk:build" (Linux) or "./gradlew.bat sdk:build" (Windows).
- Navigate to the <inline-code>build/libs<inline-code> folder in the sdk module.
- Add the jar ending in <inline-code>-all<inline-code> to your projects classpath.
Setup and Run SDK Example
Create Example Project
- Register if you have not done so already.
- Select <inline-code>Create Project<inline-code> from the <inline-code>Platform<inline-code> page.
- Give the project a name and description. The image is optional.
- Click <inline-code>Save Change<inline-code>s to create the project.
Create Example Assets
- Open your project by selecting it from the <inline-code>Platform<inline-code> page.
- Go to <inline-code>Assets<inline-code> and click <inline-code>Create Asset<inline-code>.
- 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.
- 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.