Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

SingularityNet Java SDK

CircleCI codecov Release Javadoc

Implementing SingularityNet service client in Java

  1. Create new maven project, see Maven getting started. Add Jitpack maven repo into the project to be able using SingularityNet Java SDK artifacts:


  1. Use snet-sdk-maven-plugin to get service protobuf API within your project:




              <!-- service organization id -->
              <!-- service id -->
              <!-- API output dir -->
              <!-- desired java package for classes generated -->
              <!-- Ethereum RPC endpoint to use -->




  1. Add SingularityNet Java SDK as dependency:
  1. Use protobuf-maven-plugin to generate Java stubs of service API:

  2. Write Java client app using SDK API, see as example:

    // Create SDK configuration
    Configuration config = Configuration.newBuilder()
        .setEthereumJsonRpcEndpoint("" /* + your infura project id */)
        .setIdentityPrivateKey(new byte[] { /* identity private key */ });

    // Create SDK instance
    Sdk sdk = new Sdk(config);
    try {

        // Choose payment strategy
        PaymentStrategy paymentStrategy = new OnDemandPaymentChannelPaymentStrategy();

        // Create new service client instance
        ServiceClient serviceClient = sdk.newServiceClient("snet",
                "cntk-image-recon", "default_group", paymentStrategy); 
        try {

            // Get gRPC API stub
            RecognizerBlockingStub stub = serviceClient.getGrpcStub(RecognizerGrpc::newBlockingStub);
            // Call method
            Input input = Input.newBuilder()
            Output output =;
            System.out.println("Response received: " + output);

        } finally {
            // Shutdown service client

    } finally {
        // Shutdown SDK

How to build

Integration testing is disabled by default. To run full build including integration tests use:

mvn install -DskipITs=false -P run-integration-environment

The command about automatically starts integration environment docker before running tests and stops after it. To start integration environment manually execute:

docker run -d \
    --name java-sdk-integration-environment \
    -p 5002:5002 -p 8545:8545 -p 7000:7000 \

Then you can run build with integration testing using:

mvn install -DskipITs=false

Running integration tests is a time consuming process so to make fast build running unit tests only use:

mvn install

Class diagram

Class diagram Source code