Interface RpcEndpointService

All Superinterfaces:
org.hyperledger.besu.plugin.services.BesuService

public interface RpcEndpointService extends org.hyperledger.besu.plugin.services.BesuService
This service allows you to add functions exposed via RPC endpoints.

This service will be available during the registration callback and must be used during the registration callback. RPC endpoints are configured prior to the start callback and all endpoints connected. No endpoint will actually be called prior to the start callback so initialization unrelated to the callback registration can also be done at that time.

  • Method Details

    • registerRPCEndpoint

      <T> void registerRPCEndpoint(String namespace, String functionName, Function<PluginRpcRequest, T> function)
      Register a function as an RPC endpoint exposed via JSON-RPC.

      The mechanism is a Java function that takes a PluginRpcRequest and returns any Java object, registered in a specific namespace with a function name.

      The resulting endpoint is the namespace and the functionName concatenated with an underscore to create the JSON-RPC method name.

      The request carries the raw JSON-decoded parameters of the call as an Object[]: strings, numbers, booleans, lists, and maps for JSON objects. The function is responsible for validating and converting them, and reports a failure by throwing a PluginRpcEndpointException, which is returned to the caller as a JSON-RPC error with the code and message of the exception's error.

      The output is a Java object, primitive, or array that will be inspected via Jackson databind. In general if JavaBeans naming patterns are followed those names will be reflected in the returned JSON object. If the method throws any other exception the return is an error with an INTERNAL_ERROR treatment.

      Type Parameters:
      T - specified type of return object
      Parameters:
      namespace - The namespace of the method, must be alphanumeric.
      functionName - The name of the function, must be alphanumeric.
      function - The function itself.
    • call

      PluginRpcResponse call(String methodName, Object[] params)
      Allow to call any of the enabled in-process RPC methods
      Parameters:
      methodName - the method to invoke
      params - the list of parameters accepted by the method
      Returns:
      the result of the method