npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@layerzerolabs/oft-sui-sdk

v1.2.100

Published

TypeScript SDK for LayerZero OFT Sui contracts

Readme

@layerzerolabs/oft-sui-sdk

LayerZero V2 SUI OFT (Omnichain Fungible Token) SDK

Overview

This SDK provides TypeScript bindings for interacting with LayerZero V2 OFT contracts on the SUI blockchain. It enables developers to create, manage, and transfer omnichain fungible tokens across different blockchains using the LayerZero protocol.

Installation

npm install @layerzerolabs/oft-sui-sdk
# or
yarn add @layerzerolabs/oft-sui-sdk
# or
pnpm add @layerzerolabs/oft-sui-sdk

The package is ESM only. It replaces @layerzerolabs/lz-sui-oft-sdk-v2, which also shipped a CommonJS build. CommonJS code can require it only on Node versions with require(esm) (20.19+ or 22.12+). Otherwise, use import or a dynamic import().

TypeScript consumers need moduleResolution: bundler. Under node16 or nodenext, the package's type declarations do not resolve.

Features

  • Cross-chain Transfers: Send tokens across different blockchains
  • OFT & OFT Adapter: Interact with deployed OFT & OFT Adapter
  • OFT Composer Manager: Advanced composition functionality for complex cross-chain operations

Usage

Initialize OFT

Create a new OFT that mints/burns tokens for cross-chain transfers:

import { OFT } from '@layerzerolabs/oft-sui-sdk';
import { SDK, validateTransaction } from '@layerzerolabs/lz-sui-sdk-v2';
import { Transaction } from '@mysten/sui/transactions';
import { Stage } from '@layerzerolabs/lz-definitions';

// Initialize LayerZero protocol SDK
const protocolSDK = new SDK({
    client: suiClient,
    stage: Stage.MAINNET,
});

// Create OFT instance with its call cap ID and coin type
const oft = new OFT(protocolSDK, oftCallCapId, undefined, coinType);

// Initialize OFT with treasury capability (for minting/burning)
const initTx = new Transaction();
const [adminCap, migrationCap] = oft.initOftMoveCall(
    initTx,
    coinType, // e.g., "0x123::my_coin::MY_COIN"
    oftInitTicketId, // OFT creation ticket
    oappObjectId, // Associated OApp object
    treasuryCapId, // Treasury cap for minting/burning
    metadataId, // Coin metadata
    6, // Shared decimals for cross-chain compatibility
);

// Transfer capabilities to your address
initTx.transferObjects([adminCap, migrationCap], initTx.pure.address(yourAddress));

// Execute the transaction
const result = await validateTransaction(suiClient, signer, initTx);

Initialize OFT Adapter

Create an OFT Adapter that wraps existing tokens:

// Initialize OFT Adapter (wraps existing tokens without minting/burning)
const adapterTx = new Transaction();
const [adminCap, migrationCap] = oft.initOftAdapterMoveCall(
    adapterTx,
    coinType, // e.g., "0x123::my_coin::MY_COIN"
    oftInitTicketId, // OFT creation ticket
    oappObjectId, // Associated OApp object
    metadataId, // Coin metadata
    6, // Shared decimals for cross-chain compatibility
);

// Transfer capabilities to your address
adapterTx.transferObjects([adminCap, migrationCap], adapterTx.pure.address(yourAddress));

// Execute the transaction
const result = await validateTransaction(suiClient, signer, adapterTx);

Register OFT with LayerZero Endpoint

import { validateTransaction } from '@layerzerolabs/lz-sui-sdk-v2';

// Register the OFT as an OApp with the LayerZero endpoint
const registerTx = new Transaction();

await oft.registerOAppMoveCall(
    registerTx,
    coinType, // Coin type
    oftObjectId, // Created OFT object ID
    oappObjectId, // Associated OApp object ID
    composerManagerId, // OFT Composer Manager for handling compose messages
);

// Execute the transaction
const result = await validateTransaction(suiClient, signer, registerTx);

Set Peer for Cross-Chain Communication

import { validateTransaction } from '@layerzerolabs/lz-sui-sdk-v2';

// Get OApp instance from OFT
const oapp = protocolSDK.getOApp(oft.oftCallCapId);

// Set peer OFT on destination chain
const setPeerTx = new Transaction();
await oapp.setPeerMoveCall(
    setPeerTx,
    remoteEid, // Remote chain endpoint ID (e.g., 30102 for Ethereum)
    remotePeerBytes, // Remote OFT address as 32-byte array
);

// Execute the transaction
const result = await validateTransaction(suiClient, signer, setPeerTx);

Quote and Send Tokens

// Create OFT instance with its OFT object ID and coin type
const oft = new OFT(protocolSDK, oftCallCapId, oftObjectId, coinType);

// Prepare send parameters
const sendParam = {
    dstEid: 30102, // Destination endpoint ID
    to: recipientAddressBytes, // Recipient address as Uint8Array (32 bytes)
    amountLd: 1000000n, // Amount in local decimals
    minAmountLd: 990000n, // Minimum amount (slippage protection)
    extraOptions: new Uint8Array(0), // LayerZero execution options
    composeMsg: new Uint8Array(0), // Optional compose message
    oftCmd: new Uint8Array(0), // Optional OFT command (unused in default OFT)
};

// Quote the transfer fees
const messagingFee = await oft.quoteSend(
    senderAddress,
    sendParam,
    false, // payInZro: false = pay in native token
);

// Execute the transfer
const tx = new Transaction();

// Split coins from sender's wallet
const coin = await oft.splitCoinMoveCall(tx, senderAddress, sendParam.amountLd);

// Send the tokens
await oft.sendMoveCall(
    tx,
    senderAddress,
    sendParam,
    coin,
    messagingFee.nativeFee,
    messagingFee.zroFee,
    senderAddress, // refund address
);

// Transfer any remaining coins back to sender
tx.transferObjects([coin], senderAddress);

Documentation

For detailed documentation and examples, please visit the LayerZero documentation.

License

MIT