Appearance
Introduction to the Reddio Java SDK
The Reddio Java SDK provides Java libraries to use Reddio API with Java async API.
Features
The Reddio Java SDK has the following features:
- The StarEx Cryptographic Library
- Low-Level and High-Level Reddio API clients
- Deposit, transfer, buy, sell, and withdraw assets
- Interaction with Ethereum
Prerequisites
- Oracle Java 8
- The latest version of Apache Maven
- The latest version of Gradle
Importing the Reddio Java SDK
Get the latest version on Maven Central Repository (https://search.maven.org/artifact/com.reddio/reddio-api) and import it into your project:
- For Maven:xml
<dependency> <groupId>com.reddio</groupId> <artifactId>reddio-api</artifactId> <version>VERSION</version> </dependency> - For Gradle:bash
implementation 'com.reddio:reddio-api:VERSION'
Example
Here is an example to write a script to query the user's balances with stark_key:
java
public void getBalances() throws ExecutionException, InterruptedException {
DefaultReddioRestClient restClient = DefaultReddioRestClient.testnet();
CompletableFuture<ResponseWrapper<GetBalancesResponse>> balancesFuture = restClient.getBalances(GetBalancesMessage.of(
"0x1c2847406b96310a32c379536374ec034b732633e8675860f20f4141e701ff4",
"",
100L,
1L)
);
ResponseWrapper<GetBalancesResponse> result = balancesFuture.get();
System.out.println(result.toString());
}Frequently used classes and methods
Low-Level API
ReddioRestClient:com.reddio.api.v1.rest.ReddioRestClientis theinterfaceof Low-Level API for using Reddio API, you can find the corresponding methods for each REST API.DefaultReddioRestClient:com.reddio.api.v1.rest.DefaultReddioRestClientis the implementation of Low-Level REST API, and there are two factory methods for instantiating:DefaultReddioRestClient.mainnet()andDefaultReddioRestClient.testnet().
High-Level API
ReddioClient:com.reddio.api.v1.ReddioClientis theinterfacefor High-Level API. It encapsulates the complex and boring codes for signing the request with StarEx Cryptographic Library for easy-to-use purposes.com.reddio.api.v1.ReddioClient.WithStarkExSigneris theinterfacefor Ethereum interactions like deposit and withdrawal on Layer1.WithStarkExSignercan be spawned fromReddioClientwith a private key.
DefaultReddioClient: The default implementations arecom.reddio.api.v1.DefaultReddioClientandcom.reddio.api.v1.DefaultReddioClient.DefaultWithStarkExSigner.
It is recommended to use High-Level API for a better experience.
CryptoService:com.reddio.crypto.CryptoServiceprovides interactions with StarEx Cryptographic library, like signing and Public-key cryptography-related methods.