GithubHelp home page GithubHelp logo

jaetoxi / everscale-client-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from radianceteam/everscale-client-java

0.0 0.0 0.0 19.38 MB

Java library for TON-SDK Client

License: Apache License 2.0

Java 100.00%

everscale-client-java's Introduction

Java library for Everscale Client

SDK version

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.

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 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
    $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

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

    ...
    <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();
    }

See also

everscale-client-java's People

Contributors

igor-vasilev avatar samorodkin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.