https://github.com/radianceteam/everscale-client-java
Java library for TON-SDK Client
https://github.com/radianceteam/everscale-client-java
freeton java sdk ton-client wrapper
Last synced: 5 months ago
JSON representation
Java library for TON-SDK Client
- Host: GitHub
- URL: https://github.com/radianceteam/everscale-client-java
- Owner: radianceteam
- License: apache-2.0
- Created: 2020-10-16T15:31:04.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-08-28T14:44:55.000Z (almost 3 years ago)
- Last Synced: 2024-12-05T22:20:49.748Z (over 1 year ago)
- Topics: freeton, java, sdk, ton-client, wrapper
- Language: Java
- Homepage:
- Size: 18.9 MB
- Stars: 14
- Watchers: 5
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java library for Everscale Client
[](https://github.com/tonlabs/TON-SDK/tree/1.44.2)
The Library is a binding for [Everscale Client](https://github.com/tonlabs/EVER-SDK) written in Java
that act as a bridge between Everscale Client and a Java application. The library includes original
EVER-SDK Library with incorporated support of [Java Native Interface (JNI)](https://en.wikipedia.org/wiki/Java_Native_Interface)
which allows direct access to Everscale Client from Java Virtual Machine.
### Code Generation
The most of the library source code is generated from `api.json` by script `./binding/gen-java.js`.
To use the script you must have [Node.js](https://nodejs.org/en/) installed.
### Prerequisites
- Use the following command to install Java JDK:
```
$ sudo apt-get install default-jdk
```
- Use the following command to install maven:
```
$ sudo apt-get install maven
```
- Use the following command to install rust (see also https://www.rust-lang.org/tools/install ):
```
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
- To run test, Docker Engine is required. If the Engine isn't installed the tests will be skipped.
Follow installation instructions from https://docs.docker.com/engine/install/
### Build
- To build, enter the following command:
```
$ build.sh
```
- To generate Java API Documentation, use:
```
$ mvn javadoc:javadoc
```
- You can find the generated documentation under ${Project_basedir}/binding/target/site/apidocs
- To run tests, enter the following command:
```
$ mvn test
```
- If succeed, you can find "everscale-client-binding-1.44.2-jar-with-dependencies.jar" file located under ${Project_basedir}/binding/target
### Clean
- To clean the generated files, enter the following command:
```
$ mvn clean
```
### How to use the library
Once the build succeed you will have the library installed to your local maven repository.
To use it in your projects, add the dependency to `pom.xml`
```xml
...
com.radiance.tonclient
everscale-client-binding
1.44.2
...
```
Example of usage:
```java
// At the beginning TON Context must be created
// Configuration parameters are passed as a json string
TONContext context = TONContext.create("{\"network\":{\"server_address\":\"https://net.ton.dev/graphql\"}}");
/* Alternatively TON context can be configured via ClientConfig object
TONContext context = TONContext.create(new ClientConfig(
new NetworkConfig("https://net.ton.dev/graphql")
));
*/
try {
// TON methods can be invoked via context directly ...
String randomBytes = context
.requestJSON("crypto.generate_random_bytes", "{\"length\":12}")
.get()
.findValue("bytes").asText();
System.out.println("Random bytes: '" + randomBytes + "'");
// ... or using convenience classes
Crypto crypto = new Crypto(context);
randomBytes = crypto.generateRandomBytes(12).get();
System.out.println("Random bytes: '" + randomBytes + "'");
} finally {
// context should be destroyed after using
context.destroy();
}
```
### See also
- More usage examples [test sources](binding/src/test/java/com/radiance/tonclient/)
- [Java API Docs](apidocs/)
- [Support channel](https://t.me/RADIANCE_TON_SDK)