Interface Web3jService

All Known Implementing Classes:
HttpService, IpcService, Service, UnixIpcService, WebSocketService, WindowsIpcService

public interface Web3jService
Services API.
  • Method Details

    • send

      <T extends Response> T send(Request request, Class<T> responseType) throws IOException
      Perform a synchronous JSON-RPC request.
      Type Parameters:
      T - type of a data item returned by the request
      Parameters:
      request - request to perform
      responseType - class of a data item returned by the request
      Returns:
      deserialized JSON-RPC response
      Throws:
      IOException - thrown if failed to perform a request
    • sendAsync

      <T extends Response> CompletableFuture<T> sendAsync(Request request, Class<T> responseType)
      Performs an asynchronous JSON-RPC request.
      Type Parameters:
      T - type of a data item returned by the request
      Parameters:
      request - request to perform
      responseType - class of a data item returned by the request
      Returns:
      CompletableFuture that will be completed when a result is returned or if a request has failed
    • sendBatch

      BatchResponse sendBatch(BatchRequest batchRequest) throws IOException
      Perform a synchronous JSON-RPC batch requests.
      Parameters:
      batchRequest - requests to perform
      Returns:
      deserialized JSON-RPC responses
      Throws:
      IOException - thrown if failed to perform a batch request
    • sendBatchAsync

      CompletableFuture<BatchResponse> sendBatchAsync(BatchRequest batchRequest)
      Performs an asynchronous JSON-RPC batch requests.
      Parameters:
      batchRequest - batch request to perform
      Returns:
      CompletableFuture that will be completed when a result is returned or if a request has failed
    • subscribe

      <T extends Notification<?>> io.reactivex.Flowable<T> subscribe(Request request, String unsubscribeMethod, Class<T> responseType)
      Subscribe to a stream of notifications. A stream of notifications is opened by by performing a specified JSON-RPC request and is closed by calling the unsubscribe method. Different WebSocket implementations use different pair of subscribe/unsubscribe methods.

      This method creates an Flowable that can be used to subscribe to new notifications. When a client unsubscribes from this Flowable the service unsubscribes from the underlying stream of events.

      Type Parameters:
      T - type of incoming event objects
      Parameters:
      request - JSON-RPC request that will be send to subscribe to a stream of events
      unsubscribeMethod - method that will be called to unsubscribe from a stream of notifications
      responseType - class of incoming events objects in a stream
      Returns:
      a Flowable instance that emits incoming events
    • close

      void close() throws IOException
      Closes resources used by the service.
      Throws:
      IOException - thrown if a service failed to close all resources