0x Swap logo

Catalog action EVM Onchain wallet Gas swap

Swap tokens at the best available price via 0x Protocol. Aggregates liquidity from Uniswap, Aerodrome, and other DEXes. Supports ETH and ERC20 tokens on multiple chains.

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 ID0x-swap
CategoryEVM Onchain
Connectorwallet
Requires gasYes
Funds movementswap
Tagsblockchain, evm, dex, swap, defi

Payload Schema

FieldTypeRequiredDescription
sellTokenstringYesToken address to sell. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native ETH.
buyTokenstringYesToken address to buy. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native ETH.
sellAmountstringYesAmount to sell in smallest unit (wei for ETH). Must be a positive integer string.
chainIdnumberYesChain ID (e.g., 1 for Ethereum, 8453 for Base, 42161 for Arbitrum)
slippageBpsnumberNoSlippage tolerance in basis points (100 = 1%). Default is 100 (1%). Max 5000 (50%).

Result Schema

FieldTypeRequiredDescription
statusstringYesStatus of the swap operation
transactionHashstringNoTransaction hash of the swap
sellAmountstringNoAmount of tokens sold in smallest unit
buyAmountstringNoAmount of tokens bought in smallest unit
sellTokenstringNoAddress of the token sold
buyTokenstringNoAddress of the token bought
estimatedGasstringNoEstimated gas for the transaction
approvalTransactionHashstringNoTransaction hash of the ERC20 approval. Absent when sell token is native ETH.

Examples

json
{ "type": "0x-swap", "payload": { "sellToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "buyToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "sellAmount": "1000000", "chainId": 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.

Ask a question... ⌘I