mega.swap()
Last updated
Open the wallet-managed swap flow for token exchange. The wallet handles routing UI, slippage, confirmation, and execution.
mega.swap(request: SwapRequest): Promise<TransactionResult>
fromToken
`0x${string}` / 'native'
optional
Pre-select source token.
toToken
`0x${string}` / 'native'
optional
Pre-select destination token.
const result = await mega.swap({
fromToken: 'native',
toToken: '0xTokenAddress',
});
if (result.status === 'error') {
console.error(result.error);
}Shared TransactionResult shape.
Treat cancelled as user intent — avoid hard-failing app state. For programmatic contract calls (custom swap router, batch operations), use callContract() instead.
Last updated