0x 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.
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
| Field | Value |
|---|---|
| Action ID | 0x-swap |
| Category | EVM Onchain |
| Connector | wallet |
| Requires gas | Yes |
| Funds movement | swap |
| Tags | blockchain, evm, dex, swap, defi |
Payload Schema
| Field | Type | Required | Description |
|---|---|---|---|
sellToken | string | Yes | Token address to sell. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native ETH. |
buyToken | string | Yes | Token address to buy. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native ETH. |
sellAmount | string | Yes | Amount to sell in smallest unit (wei for ETH). Must be a positive integer string. |
chainId | number | Yes | Chain ID (e.g., 1 for Ethereum, 8453 for Base, 42161 for Arbitrum) |
slippageBps | number | No | Slippage tolerance in basis points (100 = 1%). Default is 100 (1%). Max 5000 (50%). |
Result Schema
| Field | Type | Required | Description |
|---|---|---|---|
status | string | Yes | Status of the swap operation |
transactionHash | string | No | Transaction hash of the swap |
sellAmount | string | No | Amount of tokens sold in smallest unit |
buyAmount | string | No | Amount of tokens bought in smallest unit |
sellToken | string | No | Address of the token sold |
buyToken | string | No | Address of the token bought |
estimatedGas | string | No | Estimated gas for the transaction |
approvalTransactionHash | string | No | Transaction 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" }}
bashcurl -X POST "https://api.b3os.org/v1/actions/0x-swap/test" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "sellToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "buyToken": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "sellAmount": "1000000", "chainId": 8453 }}'
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.
