@interest-protocol/xbridge-sdk
v1.1.2
Published
SDK for Lattice XBridge on Sui
Readme
@lattice/xbridge-sdk
SDK for cross-chain token bridge (inbound and outbound).
Installation
bun installArchitecture
XBridge uses two separate contracts:
| Class | Direction | Description |
|-------|-----------|-------------|
| XBridgeInbound | Foreign → Sui | Mint wrapped tokens on Sui |
| XBridgeOutbound | Sui → Foreign | Lock native tokens on Sui |
Usage
Inbound (Foreign → Sui)
import { XBridgeInbound, ChainId } from '@lattice/xbridge-sdk';
const inbound = new XBridgeInbound({
suiClient,
packageId: INBOUND_PACKAGE_ID,
xbridgeInboundSharedObjectData,
xcoreSharedObjectData,
});
// Create mint request
const tx = inbound.newMintRequest({
sourceChain: ChainId.Solana,
digest,
amount: 1000000n,
fee,
coinType: '0x...::wsol::WSOL',
});
// Vote on mint request (validator)
const tx = inbound.voteMintRequest({
requestId,
voteProof,
coinType,
});Outbound (Sui → Foreign)
import { XBridgeOutbound, ChainId } from '@lattice/xbridge-sdk';
const outbound = new XBridgeOutbound({
suiClient,
packageId: OUTBOUND_PACKAGE_ID,
xbridgeOutboundSharedObjectData,
xcoreSharedObjectData,
});
// Create lock request
const tx = outbound.newLockRequest({
targetChain: ChainId.Solana,
recipient,
amount: 1000000n,
coin,
fee,
coinType: '0x2::sui::SUI',
});
// Vote on lock request (validator)
const tx = outbound.voteLockRequest({
requestId,
voteProof,
coinType,
});Wallet Keys
IMPORTANT: XBridge uses different wallet keys than XSwap.
| Chain | Wallet Key | |-------|------------| | Solana | 2 | | Sui | 3 |
Enclave Intents
| Intent | Value | Use Case | |--------|-------|----------| | Vote | 2 | Vote on mint/burn requests | | Cancel | 3 | Cancel mint request | | VoteLock | 6 | Vote on lock requests | | VoteUnlock | 7 | Vote on unlock requests | | CancelUnlock | 8 | Cancel unlock request |
Development
bun run build # Build package
bun run test # Run tests
bun run lint # Run linterDocumentation
See ../CLAUDE.md for SDK architecture patterns.
