# Upgrade guide from v2 to v3

## v3 changelog <a href="#install-the-sdk" id="install-the-sdk"></a>

Here is the high level changelog of the v3:

* The Kiln class now exposes a type safe HTTP client that exposes all Kiln Connect endpoints available. The client is generated from our OpenAPI specs. The OpenAPI typescript schema is also exposed so you can benefit from all type definitions. The schema and SDK will be updated frequently with newly added endpoints.
* The fireblocks raw signing feature is now under the fireblocks service exposed by the Kiln class. A sign method is available for all protocols we support.

## Upgrade from 2.X to 3.X <a href="#install-the-sdk" id="install-the-sdk"></a>

### Update your dependencies:

```bash
bun i @kilnfi/sdk@latest
```

### Update calls to use the http client instead of specific protocol object.

2.X:

```javascript
const k = new Kiln({
  testnet: true,
  apiToken: 'kiln_xxx',
});

const vault: Integration = {
  provider: 'fireblocks',
  fireblocksApiKey: 'YOUR_API_USER_KEY', // your fireblocks API user key
  fireblocksSecretKey: apiSecret, // your fireblocks private key (generated with your CSR file and your API user)
  vaultId: 7 // your fireblocks vault id
};

...
const tx = await k.near.craftStakeTx(
      'account_id',
      'wallet',
      'pool_id',
      0.1,
    );
const txSigned = await k.near.sign(vault, tx);
```

3.X:

```javascript
const k = new Kiln({
  baseUrl: 'https://api.testnet.kiln.fi',
  apiToken: 'kiln_xxx',
});

const vault: Integration = {
  provider: 'fireblocks',
  fireblocksApiKey: 'YOUR_API_USER_KEY', // your fireblocks API user key
  fireblocksSecretKey: apiSecret, // your fireblocks private key (generated with your CSR file and your API user)
  vaultId: 7 // your fireblocks vault id
};

const tx = await k.client.POST(
      '/v1/near/transaction/stake',
      {
        body: {
          account_id: 'account_id',
          wallet: 'wallet',
          pool_id: 'pool_id',
          amount_yocto: '1000000000000000000000000',
        }
      }
    );

const signResponse = await k.fireblocks.signNearTx(vault, tx.data.data, "NEAR_TEST");

const broadcastedTx = await k.client.POST("/v1/near/transaction/broadcast", {
      body: {
        signed_tx_serialized: signResponse.signed_tx.data.signed_tx_serialized,
      }
    });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kiln.fi/v1/kiln-products/connect/sdk/upgrade-guide-from-v2-to-v3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
