Esc

Swap

Trigger the MOSS swaps flow and know when a user has completed a swap.

Read more

import { mega } from '@megaeth-labs/wallet-sdk';

// Both fields are optional; the user picks the rest in the wallet.
const result = await mega.swap({
    fromToken: 'native',
    toToken: '0x2715b6d04b6a0AB227631019899282a585Be410F',
});
Runs on testnet with your wallet
ts
interface SwapRequest {
    fromToken?: `0x${string}` | 'native';
    toToken?: `0x${string}` | 'native';
}

// Resolves to a TransactionResult
// { status: 'approved' | 'cancelled' | 'error', receipt?, error? }