# eosio-java
**Repository Path**: mirrors_EOSIO/eosio-java
## Basic Information
- **Project Name**: eosio-java
- **Description**: EOSIO SDK for Java - API for integrating with EOSIO-based blockchains
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2023-02-28
- **Last Updated**: 2025-09-28
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README

# EOSIO SDK for Java
[](./LICENSE)



EOSIO SDK for Java is an API for integrating with EOSIO-based blockchains using the [EOSIO RPC API](https://developers.eos.io/manuals/eos/latest/nodeos/plugins/chain_api_plugin/api-reference/index). This project is compatible with server-side Java and with Android 6+.
_All product and company names are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them._
## Contents
- [Installation](#installation)
- [Helpful Utilities](#helpful-utilities)
- [Basic Usage](#basic-usage)
- [Android Example App](#android-example-app)
- [Provider Interface Architecture](#provider-interface-architecture)
- [Releases](#releases)
- [Want to Help?](#want-to-help)
- [License & Legal](#license)
## Installation
### Prerequisites
* Java JDK 1.8+ (1.8 source compatibility is targeted)
* Gradle 4.10.1+
* For Android, Android 6 (Marshmallow)+
**Note:** Android 6 (Marshmallow) was selected as the minimum target level due to Keystore security concerns in older versions of Android.
Since EOSIO SDK for Java is not an Android-specific project, we recommend using IntelliJ if you are going to work on it. You can use Android Studio but be aware that some of the menu options under Build like `Rebuild Project` and `Clean Project` will not work correctly. You may still compile within Android Studio using `Make Project` under the Build menu, or by using Gradle from the command line.
### Instructions
To use EOSIO SDK for Java in your app, add the following modules to your `build.gradle`:
```groovy
implementation 'one.block:eosiojava:1.0.0'
implementation 'one.block:eosiojavasoftkeysignatureprovider:1.0.0'
implementation 'one.block:eosiojavaandroidabieosserializationprovider:1.0.0'
implementation 'one.block:eosio-java-rpc-provider:1.0.0'
```
If you are using EOSIO SDK for Java, or any library that depends on it, in an Android application, you must also add the following to your application's `build.gradle` file in the `android` section:
```groovy
// Needed to get bitcoin-j to produce a valid apk for android.
packagingOptions {
exclude 'lib/x86_64/darwin/libscrypt.dylib'
exclude 'lib/x86_64/freebsd/libscrypt.so'
exclude 'lib/x86_64/linux/libscrypt.so'
}
```
The `build.gradle` files for the project currently include configurations for publishing the project to Artifactory and Bintray. These should be removed if you are not planning to use Artifactory and Bintray or you will encounter build errors. To do so, make the changes marked by comments throughout the files.
Then refresh your gradle project. Then you're all set for the [Basic Usage](#basic-usage) example!
## Helpful Utilities
One of the most complicated and time consuming tasks about encryption can be figuring out how to transform keys into a format that works on the target blockchain. This library includes two utilities that make that process painless. The `EOSFormatter` and `PEMProcessor` classes include methods that allow you to convert a PEM or DER encoded public or private key to and from the standard EOS formats. The `PEMProcessor` wraps a key and gives you the ability to extract the type, the DER format, the algorithm used to generate the key, and to perform a checksum validation. The `EOSFormatter` utility converts keys between DER or PEM and the EOS format and formats signatures and transactions into an EOS compliant format as well. There is an abundance of documentation on the Internet about converting keys and signatures to a DER encoded or PEM (Privacy Enhanced Mail) format (See [PEM](https://tools.ietf.org/html/rfc1421) and [DER](https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf)). If you can get your key into one of these formats we provide a simple transition to the EOS format.
## Basic Usage
Transactions are instantiated via a `TransactionSession()` which must be configured with a number of providers and a `TransactionProcessor()`, which manipulates and performs actions on a Transaction, prior to use. The code below shows a very barebones flow. Error handling has been omitted for clarity but should be handled in normal usage. (See [Provider Interface Architecture](#provider-interface-architecture) below for more information about providers.)
Some parameters for transaction processing can be altered by the use of the `TransactionConfig`. These are `useLastIrreversible`, `blocksBehind` and `expiresSeconds`. `TransactionConfig` defaults to `useLastIrreversible` equal to true, `blocksBehind` to 3 and `expiresSeconds` to 300. When `useLastIrreversible` is true, `blocksBehind` is ignored and `TransactionProcessor` uses the last irreversible block and `expiresSeconds` to calculate TAPOS. Otherwise, `TransactionProcessor` uses the current head block minus the number specified in `blocksBehind` and `expiresSeconds` for TAPOS. `TransactionConfig` defaults to `useLastIrreversible` to lessen the chances of transactions micro-forking under certain conditions.
```java
IRPCProvider rpcProvider = new EosioJavaRpcProviderImpl("https://baseurl.com/v1/");
ISerializationProvider serializationProvider = new AbiEosSerializationProviderImpl();
IABIProvider abiProvider = new ABIProviderImpl(rpcProvider, serializationProvider);
ISignatureProvider signatureProvider = new SoftKeySignatureProviderImpl();
signatureProvider.importKey(privateKeyK1EOS);
// or...
signatureProvider.importKey(privateKeyR1EOS);
TransactionSession session = new TransactionSession(
serializationProvider,
rpcProvider,
abiProvider,
signatureProvider
);
TransactionProcessor processor = session.getTransactionProcessor();
// Now the TransactionConfig can be altered, if desired
TransactionConfig transactionConfig = processor.getTransactionConfig();
// Use blocksBehind (default 3) the current head block to calculate TAPOS
transactionConfig.setUseLastIrreversible(false);
// Set the expiration time of transactions 600 seconds later than the timestamp
// of the block used to calculate TAPOS
transactionConfig.setExpiresSeconds(600);
// Update the TransactionProcessor with the config changes
processor.setTransactionConfig(transactionConfig);
String jsonData = "{\n" +
"\"from\": \"person1\",\n" +
"\"to\": \"person2\",\n" +
"\"quantity\": \"10.0000 EOS\",\n" +
"\"memo\" : \"Something\"\n" +
"}";
List authorizations = new ArrayList<>();
authorizations.add(new Authorization("myaccount", "active"));
List actions = new ArrayList<>();
actions.add(new Action("eosio.token", "transfer", authorizations, jsonData));
processor.prepare(actions);
SendTransactionResponse sendTransactionResponse = processor.signAndBroadcast();
// Starting with EOSIO 2.1 actions can have return values associated with them.
// If the actions have return values they can be accessed from the response.
ArrayList