> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layerzero.network/llms.txt
> Use this file to discover all available pages before exploring further.

# LayerZero V2 Solana OFT SDK

> Use the Solana OFT SDK to interact with LayerZero OFTs on Solana. Build crosschain token transfers with the oft-v2-solana-sdk. Build omnichain tokens with L...

You can use the Solana OFT SDK - [@layerzerolabs/oft-v2-solana-sdk
](https://www.npmjs.com/package/@layerzerolabs/oft-v2-solana-sdk) library to interact with your Solana OFT.

Setting up a project using the LayerZero CLI would have given you scripts under the [tasks/solana](https://github.com/LayerZero-Labs/devtools/tree/main/examples/oft-solana/tasks/solana) folder that utilizes the Solana OFT SDK. You can refer to [tasks/common/sendOFT.ts](https://github.com/LayerZero-Labs/devtools/blob/main/examples/oft-solana/tasks/common/sendOFT.ts) for the example usage.

## Using the Solana OFT SDK in the Frontend

The Solana OFT SDK has been updated to be browser-compatible. Versions prior to `3.0.71` required more additional configurations via your bundling tool.

<Tabs>
  <Tab title="Next">
    For Next projects, no additional configurations are required to use the Solana OFT SDK.
  </Tab>

  <Tab title="Vite">
    For Vite projects, the following are the minimal configurations required to work. `nodePolyfills` is required as `Buffer` is required by `@solana/web3.js` but Vite does not polyfill it by default.

    ```typescript wrap theme={null}
    // vite.config.ts
    import {defineConfig} from 'vite';
    import react from '@vitejs/plugin-react';
    import {nodePolyfills} from 'vite-plugin-node-polyfills';

    // https://vite.dev/config/
    export default defineConfig({
      plugins: [react(), nodePolyfills()],
    });
    ```
  </Tab>
</Tabs>

### Requirements

* `@layerzerolabs/oft-v2-solana-sdk@^3.0.86`
* `@layerzerolabs/lz-v2-utilities@^3.0.86`
* `@layerzerolabs/lz-definitions@^3.0.86`
* `@metaplex-foundation/umi@^0.9.2`
* `@metaplex-foundation/umi-bundle-defaults@^0.9.2`
* `@metaplex-foundation/umi-signer-wallet-adapters@^0.9.2`
* `@solana/web3.js@^1.95.8`

#### Applying overrides for `@solana/web3.js`

In `package.json` add the following `resolutions` / `overrides` to ensure a consistent version of `@solana/web3.js` is used:

<CodeGroup>
  ```npm theme={null}
  "overrides": {
    "@solana/web3.js": "~1.95.8"
  }
  ```

  ```pnpm theme={null}
  "pnpm": {
    "overrides": {
      "@solana/web3.js": "~1.95.8"
    }
  }
  ```

  ```yarn theme={null}
  "resolutions": {
      "@solana/web3.js": "~1.95.8"
  }
  ```
</CodeGroup>

## Compatibility with `@solana/web3.js`

Under the hood, uses `@metaplex-foundation/umi`, which is an alternative to `@solana/web3.js`.

If your project is using `@solana/web3.js`, you can utilize [adapters for @solana/web3.js](https://developers.metaplex.com/umi/web3js-differences-and-adapters).

## Troubleshooting

### `Invalid Connection`

This can occur when there are multiple incompatible versions of `@solana/web3.js`. We need to ensure a consistent version is used due to the usage of `@metaplex-foundation/umi@^0.9.2`.

To verify that this is the issue, run `npm ls @solana/web3.js` and check whether there are multiple versions of `@solana/web3.js` in the output.

To solve this issue, do the following:

* delete your `node_modules` folder
* delete your package manager's lockfile
* in your package.json, specify `@solana/web3.js@^1.95.8` as the dependency and also [apply overrides](#applying-overrides-for-solanaweb3js)
* rerun your package manager install command.
