Java SDK for Fireblocks

Hi,

I need a java SDK, does anyone know of a good open source java sdk project for Fireblocks?

Hi @moza !

There is no official Java SDK for Fireblocks, but you can find instructions and examples for working with the Fireblocks API in Java here: Java Guide.

You can also check out this repository, although it is a bit outdated and is not maintained by Fireblocks.

Another available option is to use https://editor.swagger.io/. You can paste in the Fireblocks OpenAPI 3.0 spec, then select Generate Client > Java. This will generate and download a custom SDK based on the spec. Please note that Fireblocks can only guarantee the correctness of the spec, and not any specific correctness or functionality of the SDK that Swagger creates.

1 Like

Hey @moza ! Is this for working mainly with EVM blockchains?

If so, you might want to give the fireblocks-json-rpc project a try together with web3j

1 Like

Thank you Alec so I am going off of this project called proximax (GitHub - proximax-storage/java-xpx-chain-sdk: ProximaX Sirius-Chain Java SDK), they create and maintain their SDK using openApiGenerate. Using openApiGenerate I was able to generate all my java SDK code. Now I am stuck on something obvious, I generated a APIClient that takes in a x-API-Key and bearerTokenAuth. I can’t figure what field should I use for the API token and which one I should use for the secret key generated with the cert. Here is the code that’s requesting it authentications.put("ApiKeyAuth", new ApiKeyAuth("header", "X-API-Key")); authentications.put("bearerTokenAuth", new HttpBearerAuth("bearer"));

Hi @moza -

If you have created an API User in Fireblocks, you can copy the API key in the Fireblocks Console. This is the “X-API-Key”. The bearer auth token is a JWT requiring fields that are described here. You can check out example in the Java Guide I sent above to see how we build and sign the JWT.

1 Like

Thank you! After debugging through the generated code, we found that there is ApiClient class that you need to use to authenticate to Fireblocks. The ApiClient is annoying because it has setBearerToken and setAPIKey methods, those are pretty useless. Instead we had to use the addDefaultHeaders method and pass the API key and bearer token. Here is example code in setting that up.

  /** Setting up the ApiClient */
  public void initializeApiClient() {

    //    apiClient = new ApiClient(restTemplate);

    // Setting the ApiKey
    apiClient.setApiKey(apiKey);
    apiClient.addDefaultHeader("X-API-Key", apiKey);
  }

  public void setJWT(String path) {
    // Setting the Auth Bearer JWT Token
    String privateKeyPem = readPrivateKeyFromFile(secretKeyPath);
    JwtTokenGenerator jwtTokenGenerator = new JwtTokenGenerator(apiKey, privateKeyPem);
    String jwtToken = jwtTokenGenerator.generateJwtTokenForGet(path);
    apiClient.addDefaultHeader("Authorization", "Bearer " + jwtToken);
    apiClient.setBearerToken(jwtToken);
  }

There is official sdk now GitHub - fireblocks/java-sdk, it’s little outdated, but usable.

1 Like