Cross-Chain Swap (Relay) logo

Catalog action EVM Onchain wallet Gas bridge

Swap tokens at the best available price via Relay Protocol. The default swap action for buying and selling tokens. Supports EVM and Solana sources, same-chain swaps, cross-chain swaps, and bridging. Configurable slippage.

This action can require a wallet connector, gas, token movement, or an external side effect. Test with simulation or a controlled amount before using it in a live workflow.

At a Glance

FieldValue
Action IDrelay-swap
CategoryEVM Onchain
Connectorwallet
Requires gasYes
Funds movementbridge
Tagsblockchain, evm, solana, dex, swap, sell, buy, token, erc20, trade, bridge, cross-chain

Payload Schema

FieldTypeRequiredDescription
srcChainIdnumberYesSource chain ID (e.g., 1 for Ethereum, 8453 for Base, or 7565164 for Solana mainnet). Relay's 792703809 and LI.FI's 1151111081099710 are accepted as Solana mainnet aliases.
tokenInstringYesSource token address or Solana SPL mint. Use "native" for the source chain's native token (including SOL); EVM native-token sentinels are also accepted.
amountInstringNoExact input amount to sell in smallest unit (wei for ETH). Provide either amountIn (EXACT_INPUT) or amountOut (EXACT_OUTPUT), not both.
amountOutstringNoDesired output amount to receive in smallest unit. When provided, Relay quotes the minimum amountIn needed to receive this amount (EXACT_OUTPUT mode). Provide either amountIn or amountOut, not both.
dstChainIdnumberYesDestination chain ID. Can be same as srcChainId for same-chain swaps or different for cross-chain. Use 7565164 for Solana mainnet (792703809 and 1151111081099710 are accepted as aliases for that same network).
tokenOutstringYesDestination token address. Use "native" for the destination chain's native token on any chain, including native SOL on Solana (0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE and 0x0000000000000000000000000000000000000000 also work on EVM chains). For other tokens use the chain's address format (e.g., base58 SPL mint for Solana).
recipientstringNoRecipient address for the output tokens. Defaults to sender for same-family swaps. Required when crossing between EVM and Solana.
useMaxTokenInBalancebooleanNoWhen true and tokenIn is a native EVM token, subtracts estimated gas cost from amountIn (based on current gas price). Useful when bridging all native ETH cross-chain, where amountIn is the full balance and gas must be reserved. Only applies to native EVM tokens.
slippageBpsnumberNoSlippage tolerance in basis points (100 = 1%). Default is 300 (3%). Max 8000 (80%).

Result Schema

FieldTypeRequiredDescription
statusstringYesStatus of the swap operation
srcTransactionHashstringNoTransaction hash on the source chain
dstTransactionHashstringNoTransaction hash on the destination chain (for cross-chain swaps)
amountInstringNoInput amount that was swapped (actual amount sold, useful in EXACT_OUTPUT mode).
amountInFormattedstring | nullNoInput amount in human-readable units (amountIn ÷ 10^inputDecimals), full precision. Null when the input token's decimals are unavailable. Prefer this over amountIn for display.
amountOutstringNoOutput amount received. Receipt-parsed on EVM destinations; on non-EVM destinations (e.g. Solana) this is Relay's quoted estimate — actual delivery can be lower within the slippage tolerance.
amountOutFormattedstring | nullNoOutput amount in human-readable units (amountOut ÷ 10^decimals), full precision. Null when the output token's decimals are unavailable. Prefer this over amountOut for display — it needs no client-side math. Carries amountOut's caveat: a quoted estimate on non-EVM destinations.
srcChainIdnumberNoSource chain ID
dstChainIdnumberNoDestination chain ID
tokenInSymbolstring | nullNoSymbol of the INPUT token that was swapped (e.g. 'USDC'). Lets the UI label the source token correctly.
tokenSymbolstring | nullNoSymbol of the output token received (e.g., 'JUP'). Lets the UI label the destination token when on-chain token lookup is unavailable (e.g., Solana SPL mints).
decimalsnumber | nullNoDecimal places of the output token, used to format the received amount when on-chain token lookup is unavailable.

Examples

json
{ "type": "relay-swap", "payload": { "tokenIn": "ETH", "tokenOut": "ETH", "srcChainId": 8453, "dstChainId": 8453 }, "children": [], "connector": { "type": "wallet", "id": "conn_wallet" }}

Payload fields can use workflow expressions such as {{$trigger.body.amount}}, {{$nodes.fetch.result.price}}, and {{$props.asset}} when the value should come from a trigger, prior node, or reusable workflow prop.