Installation
Install both the core Sui SDK and the OFT-specific SDK:Setup
Initialize the SDKs
The recommended pattern uses automatic address fetching from the protocol SDK:- First parameter: Use your OFT package ID (where your code is deployed)
- SDK automatic addresses: No need to hardcode LayerZero protocol addresses
- Optional parameters: Can be
undefinedinitially and set later - After initialization: Update
oft.oftObjectId = newObjectId
new OApp(...) - this will fail to find your OApp in the registry. Always use sdk.getOApp(packageId).
SDK Architecture
The Sui OFT SDK consists of two complementary SDKs:Base SDK (@layerzerolabs/lz-sui-sdk-v2)
Provides core LayerZero protocol functionality:
- OApp operations: Peer configuration, messaging, registration
- Endpoint interaction: Channel initialization, library configuration
- DVN/Executor configuration: Security stack setup
- Protocol address exports: All deployed contract addresses
OFT SDK (@layerzerolabs/lz-sui-oft-sdk-v2)
Extends the base SDK with OFT-specific functionality:
- OFT initialization:
initOftMoveCall(),initOftAdapterMoveCall() - Registration:
registerOAppMoveCall()(auto-generates lz_receive_info) - Rate limiting: Per-pathway token flow limits
- Fee management: Crosschain fee configuration
- Pause control: Emergency pause functionality
Relationship
SDK Address Exports
The SDK provides address exports for all protocol contracts, eliminating hardcoded values:- Network switching: Toggle between mainnet/testnet via
Stageenum - SDK updates: Address changes handled automatically
- No magic numbers: Self-documenting configuration
- Type safety: TypeScript ensures correct usage
| Export | Description | Usage |
|---|---|---|
OBJECT_ENDPOINT_V2_ADDRESS | Endpoint shared object | Pass to Endpoint functions |
OBJECT_ULN_302_ADDRESS | ULN302 shared object | Pass to ULN302 functions |
PACKAGE_OAPP_ADDRESS | OApp package ID | Reference for OApp code |
PACKAGE_ULN_302_ADDRESS | ULN302 package ID | Use in move call targets |
PACKAGE_DVN_LAYERZERO_ADDRESS | LayerZero DVN package | DVN configuration |
OAppUlnConfigBcs | Config serializer | Encode DVN configuration |
Complete Working Example
Based on proven mainnet deployment:oft.initOftMoveCall()- Initialize OFT with treasuryoft.registerOAppMoveCall()- Register and auto-generate lz_receive_infosdk.getOApp()- Get OApp instance for configurationoapp.setPeerMoveCall()- Configure peer addressesoapp.setConfigMoveCall()- Configure DVNs/executors
Available SDK Methods
Base SDK (OApp Operations)
The base SDK provides methods for OApp configuration throughsdk.getOApp(packageId):
OFT SDK Methods
The OFT SDK provides token-specific operations:Core Methods
quote()
Get a fee quote for sending tokens crosschain:send()
Send tokens crosschain:getOFTConfig()
Read OFT configuration:getPeer()
Get peer OFT address for a specific chain:Building Execution Options
Use theOptions helper from the core SDK:
Gas Limits by Destination
| Destination | Recommended Gas Limit | Notes |
|---|---|---|
| EVM chains | 60,000 - 200,000 | Higher for complex logic |
| Solana | 200,000 | May need msg.value for ATA |
| Sui | 200,000+ | May need msg.value for object creation |
| Aptos | 100,000 | Adjust based on complexity |
msg.value Considerations
When sending to Sui, you may need to includemsg.value for:
- Creating a new coin object for the recipient
- Storage rent for the new object
Complete Example
Sending Tokens from Sui to Ethereum
Reading Token Balances
Check OFT token balances using the Sui client:Integration with Core SDK
The OFT SDK builds on the core Sui SDK:Error Handling
Common errors and how to handle them:Admin Functions
The SDK provides admin functions for OFT management (requiresAdminCap):
Pause/Unpause
Fee Configuration
Rate Limiting
Peer Configuration
Best Practices
- Always Quote First: Get fee estimates before sending
- Set Slippage: Use
minAmountLDto protect against dust/precision loss - Check Balances: Verify sufficient tokens and SUI for gas
- Use TypeScript: Leverage type safety for parameter validation
- Test on Testnet: Always test on testnet before mainnet deployments
- Monitor Rate Limits: Configure appropriate limits for production
- Secure Admin Cap: Use multisig or hardware wallet for admin operations
Next Steps
- OFT Overview - OFT architecture and deployment guide
- Configuration Guide - DVN, executor, and gas setup
- OApp Overview - Base messaging standard
- Technical Overview - Sui fundamentals and architecture
- Protocol Overview - Complete message workflows
- Troubleshooting - Common SDK issues