The Library is a binding for Everscale Client 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) which allows direct access to Everscale Client from Java Virtual Machine.
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 installed.
- 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/
- 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
- To clean the generated files, enter the following command:
$ mvn clean
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
...
<dependency>
<groupId>com.radiance.tonclient</groupId>
<artifactId>everscale-client-binding</artifactId>
<version>1.44.2</version>
</dependency>
...
Example of usage:
// 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();
}
- More usage examples test sources
- Java API Docs
- Support channel