Cross-chain token transfers and swaps across 20+ blockchains. Built on LI.FI with simple, standardized API.
⚠️ Alpha Release: APIs may change. Not production-ready.
npm install @m3s/crosschain
import { createCrossChain } from '@m3s/crosschain';
import { createWallet } from '@m3s/wallet';
// Setup wallet
const wallet = await createWallet({
name: 'ethers',
options: { privateKey: 'YOUR_PRIVATE_KEY' }
});
// Create crosschain adapter
const crosschain = await createCrossChain({
name: 'lifi',
version: '1.0.0',
options: {
apiKey: process.env.LIFI_API_KEY // Optional for quotes
}
});
// Get quotes for cross-chain transfer
const quotes = await crosschain.getOperationQuote({
sourceAsset: {
chainId: 137, // Polygon
address: '0x...', // USDC
symbol: 'USDC',
decimals: 6
},
destinationAsset: {
chainId: 10, // Optimism
address: '0x...', // USDC
symbol: 'USDC',
decimals: 6
},
amount: '100000000', // 100 USDC
userAddress: await wallet.getAccounts()[0],
slippageBps: 50 // 0.5%
});
// Execute best quote
const result = await crosschain.executeOperation(quotes[0]);
console.log(`Transfer started: ${result.operationId}`);
// Track status
const status = await crosschain.getOperationStatus(result.operationId);
console.log(`Status: ${status.status}`);
- 20+ Chains - All major EVM networks supported
- Route Optimization - Find best paths automatically
- Gas Estimation - Accurate cost estimates
- Status Tracking - Real-time operation monitoring
- LI.FI Integration - Access to 15+ bridge protocols
Network | Chain ID | Native Token |
---|---|---|
Ethereum | 1 | ETH |
Polygon | 137 | MATIC |
Arbitrum | 42161 | ETH |
Optimism | 10 | ETH |
Base | 8453 | ETH |
BNB Chain | 56 | BNB |
Avalanche | 43114 | AVAX |
// MATIC on Polygon → WETH on Arbitrum
const quotes = await crosschain.getOperationQuote({
sourceAsset: { chainId: 137, address: '0x...', symbol: 'MATIC' },
destinationAsset: { chainId: 42161, address: '0x...', symbol: 'WETH' },
amount: ethers.parseEther('100').toString(),
userAddress: userAddress
});
// Custom slippage and bridge preferences
const quotes = await crosschain.getOperationQuote({
// ... assets ...
options: {
slippage: 0.005, // 0.5%
allowBridges: ['stargate', 'across'],
denyExchanges: ['paraswap']
}
});
// Poll for updates
const checkStatus = async (operationId) => {
const status = await crosschain.getOperationStatus(operationId);
console.log(`Status: ${status.status}`);
if (status.sourceTx?.hash) {
console.log(`Source TX: ${status.sourceTx.hash}`);
}
if (status.destinationTx?.hash) {
console.log(`Destination TX: ${status.destinationTx.hash}`);
}
};
Extend to more bridges and protocols:
- 📖 Full Documentation - Complete API reference
- 🧪 Live Demo - Try cross-chain transfers
- 🔧 Adapter Templates - Create bridge adapters
MIT