Creating user tools (applications) on the basis of the Credits API and Java
Requirements
JDK 8
Java IDE (optional, JetBrains IntelliJ is considered)
Text editor (for example, Visual Studio Code)
Maven (installation is described in the "Installing Maven on Windows 10" article)
GIT (installation)
Installing GitHub for Windows. Its installer includes command-line utilities and a Git GUI. It also works correctly with Powershell, provides clear credential retention, and correct CRLF settings. You can download GitHub for Windows from http://windows.github.com.
Verifying the installation:
git --version
result (git version 2.17.1.windows.2)
Assembly. Sequence of steps
After preliminary requirements are met, the next step is to take the project from GitHub https://github.com/CreditsCOM/CS-Wallet-desktop, which is Credits Desktop Wallet app. It is downloaded using the following command:
git clone https://github.com/CreditsCOM/CS-Wallet-desktop.git
folder contents after download
Assume that the project is located at this path: D:\dev\Credits\CS-Wallet-desktop\
Next, run CMD and go to the CS-Wallet-desktop folder as shown below
in this folder go to the leveldb-client by the command
cd leveldb-client
in the folder type:
mvn compile
next
mvn package
the result is a leveldb-client.jar file in D:\dev\Credits\CS-Wallet-desktop\leveldb-client\target folder
Creating an application in JetBrains IntelliJ
Step 1. A simple Maven project is created
Step 2. File install-to-rep.bat is launched from the D:\dev\Credits\CS-Wallet-desktop\leveldb-client\ folder to register the leveldb-client.jar library
Step 3. Dependencies are added in pom.xml of our file:
<dependencies>
<dependency>
<groupId>com.Credits</groupId>
<artifactId>leveldb-client</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
Step 4. Example of a simple application source file:
import com.Credits.common.exception.CreditsCommonException;
import com.Credits.common.utils.Converter;
import com.Credits.leveldb.client.ApiClient;
import com.Credits.leveldb.client.exception.CreditsNodeException;
import com.Credits.leveldb.client.exception.LevelDbClientException;
import java.math.BigDecimal;
public class app {
public static void main(String[] args) throws CreditsCommonException, LevelDbClientException, CreditsNodeException {
String account = "6zxLh3nbbtxt36ED211Y3askbbSY4E1iV98TKcFzjoUk";
ApiClient client = ApiClient.getInstance("127.0.0.1", 9090);
BigDecimal balance = client.getBalance(Converter.decodeFromBASE58(account), (byte)1);
System.out.print(balance);
}
}
Check. Running the application
Check. Running the application
Assembling the application:
in the folder of our application execute the following commands from CMD
mvn compile
mvn package
Running the application through Maven looks like this:
mvn -e exec:java -Dexec.mainClass="com.Credits.wallet.desktop.App"
Result: