LayerZero V2 Solana OFT SDK
You can use the Solana OFT SDK - @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 folder that utilizes the Solana OFT SDK. You can refer to tasks/solana/sendOFT.ts for the example usage.
Using the Solana OFT SDK in the Frontend
The Solana OFT SDK was recently updated (in version 3.0.57
) to be more browser-compatible. Versions prior to this required more additional configurations via your bundling tool.
From 3.0.57
onwards, you can use the Solana OFT SDK with these minimal configurations:
- Next.js
- Vite
// next.config.ts
import type {NextConfig} from 'next';
const nextConfig: NextConfig = {
webpack: (config) => {
config.resolve.fallback = {
fs: false,
module: false,
};
return config;
},
};
export default nextConfig;
// 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()],
});
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.