---
updatedAt: 2026-05-14T11:27:34.000Z
---

Fetch the complete documentation index at: https://docs.blockdaemon.com/llms.txt. Use this file to discover all available pages before exploring further. Append .md to any documentation page URL to get its markdown version.

# Create DEX Swap Transaction with Approval

Generates both token approval and swap transactions in a single call with configurable slippage protection.

> 💡 
**Compute Unit Value:** `85` (Fixed)

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "contact": {
      "name": "Blockdaemon",
      "email": "info@blockdaemon.com"
    },
    "description": "The Blockdaemon DeFi API provides a single interface to a multitude of DeFi projects and blockchains",
    "title": "Blockdaemon DeFi API",
    "version": "1.0.0",
    "x-logo": {
      "altText": "Blockdaemon logo",
      "backgroundColor": "#fafafa",
      "url": "https://storage.googleapis.com/blockdaemon-app-static-images/marketing/PNG/dark-logo.png"
    }
  },
  "externalDocs": {
    "description": "Blockdaemon DeFi documentation",
    "url": "http://www.blockdaemon.com/api/defi"
  },
  "servers": [
    {
      "url": "https://svc.blockdaemon.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "`X-API-Key: <Token>` header must be set to authenticate API requests.You can create tokens in the \"Configure\" tab of your API access area at https://app.blockdaemon.com."
      }
    },
    "schemas": {
      "_dex_swapwithapproval_Request": {
        "type": "object",
        "properties": {
          "dexId": {
            "type": "string",
            "description": "The unique ID to specify the decentralized exchange (DEX) within a particular blockchain. Find more [here](https://docs.blockdaemon.com/docs/defi-api-supported-protocols#supported-dexs-protocols).",
            "enum": [
              "1000",
              "1001",
              "1300",
              "1301",
              "1305",
              "1306",
              "1307",
              "1308",
              "1309",
              "1310",
              "1100",
              "1101",
              "1200",
              "1201",
              "2900",
              "2901",
              "2800",
              "2808",
              "2809",
              "1500",
              "1400",
              "1402",
              "2300",
              "2100",
              "2101",
              "2500",
              "2501",
              "2700",
              "2600",
              "2400",
              "2401",
              "1600",
              "1602",
              "1604",
              "1605",
              "1607",
              "1608",
              "1700",
              "1701",
              "1702",
              "1703",
              "1704",
              "1706",
              "1707",
              "2200",
              "2201",
              "2202",
              "2203",
              "2204",
              "2205",
              "2206",
              "3000",
              "3001",
              "3100",
              "3300",
              "3301",
              "3500",
              "3501",
              "3400",
              "3401",
              "3600",
              "3800",
              "3700"
            ],
            "example": "1000"
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ordered array of token contract addresses defining the swap route. Provide [tokenInAddress, tokenOutAddress] for a direct swap. Example (WETH→USDC on Ethereum): ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'].",
            "example": [
              "0x514910771AF9Ca656af840dff83E8264EcF986CA",
              "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
            ]
          },
          "amountIn": {
            "type": "string",
            "description": "Amount of the input token to provide, specified in the token's smallest denomination (base units). Do not send human-readable decimal values. Examples: to swap 1 WETH (18 decimals), use \"1000000000000000000\"; to swap 1 USDC (6 decimals), use \"1000000\".",
            "example": "1000000000000000000"
          },
          "amountOutMin": {
            "type": "string",
            "description": "Minimum acceptable output amount in the token's smallest denomination (base units). Provides slippage protection — the transaction reverts if the output falls below this value. Set to \"0\" to disable slippage protection. Examples: to require at least 0.99 USDC (6 decimals), use \"990000\"; to require at least 0.99 WETH (18 decimals), use \"990000000000000000\".",
            "example": "0"
          },
          "to": {
            "type": "string",
            "description": "Blockchain address of the token recipient. For EVM chains, use a checksummed hex address (e.g., 0xABCDEF...). Output tokens are delivered to this address after the swap.",
            "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
          },
          "deadline": {
            "type": "string",
            "description": "Transaction expiry time as a Unix timestamp in seconds (not milliseconds). The transaction will revert if not submitted before this time. Example: to set a 20-minute deadline, use current Unix timestamp + 1200.",
            "example": "1707313948"
          },
          "from": {
            "type": "string",
            "description": "Blockchain address of the token sender. For EVM chains, use a checksummed hex address (e.g., 0xABCDEF...). This address must hold sufficient balance of the input token and will sign the transaction.",
            "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
          },
          "gas": {
            "type": "string",
            "description": "Maximum number of gas units to allocate for the transaction, as an integer string (e.g., '200000'). If omitted, gas is estimated automatically. Note: this is gas units, not wei or gwei.",
            "example": "100000"
          },
          "gasPriority": {
            "type": "string",
            "description": "Specifies the priority level for gas fees (e.g., 'low', 'medium', or 'high'), which influences the transaction speed and cost.",
            "example": "low"
          },
          "slippage": {
            "type": "string",
            "description": "Maximum acceptable slippage as a percentage of the swap value. Valid range: 0 to 100 (e.g., 1 = up to 1% slippage). Defaults to 1. The transaction reverts if the output deviates more than this percentage from the quoted price.",
            "example": "10"
          },
          "enableFee": {
            "type": "boolean",
            "description": "Flag to include a basis points fee transaction alongside the main transaction when set to true.",
            "example": false
          },
          "batchOption": {
            "type": "string",
            "description": "Transaction batching standard to use. Supported values: 'EIP-5792' (wallet-level batching via wallet_sendCalls) or 'EIP-7702' (EOA code delegation via batcherContract). Requires batcherContract when using EIP-7702.",
            "enum": [
              "EIP-5792",
              "EIP-7702"
            ],
            "example": "EIP-5792"
          },
          "batcherContract": {
            "type": "string",
            "description": "The EOA address of the batcher that will be used to execute the transaction when using EIP-7702 batching. If not provided, the default batcher contract for the chain will be used.",
            "example": "0x9c933f9d2efd76ce25b0d3dde84d3f94e78a50ca"
          },
          "simulate": {
            "type": "boolean",
            "description": "When true, dry-runs the transaction batch via eth_simulateV1 and returns a simulate field with status and error on each transaction.",
            "example": false
          },
          "poolFees": {
            "type": "string",
            "description": "Fee tier of the target liquidity pool in basis points (1 bp = 0.01%). Common values for Uniswap V3-style AMMs: 100 (0.01%), 500 (0.05%), 3000 (0.3%), 10000 (1%). If omitted, the pool yielding the highest output amount is selected automatically.",
            "example": "3000"
          }
        },
        "required": [
          "path",
          "amountIn",
          "to",
          "deadline",
          "from"
        ],
        "description": "The request body for a /defi/v1/dex/swap-with-approval",
        "example": {
          "dexId": "1000",
          "path": [
            "0x514910771AF9Ca656af840dff83E8264EcF986CA",
            "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
          ],
          "amountIn": "1000000000000000000",
          "amountOutMin": "0",
          "to": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
          "deadline": "1707313948",
          "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
          "gas": "100000",
          "gasPriority": "low",
          "slippage": "10",
          "enableFee": false,
          "batchOption": "EIP-5792",
          "batcherContract": "0x9c933f9d2efd76ce25b0d3dde84d3f94e78a50ca",
          "simulate": false,
          "poolFees": "3000"
        }
      }
    }
  },
  "tags": [
    {
      "name": "dex",
      "description": "API endpoints for operations related to decentralized exchange"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/defi/v1/dex/swap-with-approval": {
      "post": {
        "tags": [
          "dex"
        ],
        "summary": "Create DEX Swap Transaction with Approval",
        "description": "Generates both token approval and swap transactions in a single call with configurable slippage protection.\n\n> 💡 \n**Compute Unit Value:** `85` (Fixed)",
        "operationId": "dexSwapWithApproval",
        "requestBody": {
          "required": true,
          "description": "The request body for a /defi/v1/dex/swap-with-approval",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/_dex_swapwithapproval_Request"
              },
              "example": {
                "dexId": "1000",
                "path": [
                  "0x514910771AF9Ca656af840dff83E8264EcF986CA",
                  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
                ],
                "amountIn": "1000000000000000000",
                "amountOutMin": "0",
                "to": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
                "deadline": "1707313948",
                "from": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402",
                "gas": "100000",
                "gasPriority": "low",
                "slippage": "10",
                "enableFee": false,
                "batchOption": "EIP-5792",
                "batcherContract": "0x9c933f9d2efd76ce25b0d3dde84d3f94e78a50ca",
                "simulate": false,
                "poolFees": "3000"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "number",
                      "description": "Numeric status code indicating success or failure of the API call",
                      "example": 200
                    },
                    "msg": {
                      "type": "string",
                      "description": "Human-readable message describing the API result or error"
                    },
                    "data": {
                      "oneOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "chainId": {
                                "type": "string",
                                "description": "Blockchain network identifier (EVM chain ID, Solana chain name, etc.)",
                                "example": "1"
                              },
                              "from": {
                                "type": "string",
                                "description": "Sender's wallet address",
                                "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                              },
                              "to": {
                                "type": "string",
                                "description": "Recipient's wallet address",
                                "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                              },
                              "gas": {
                                "type": "string",
                                "description": "Gas limit for the transaction",
                                "example": "100000"
                              },
                              "value": {
                                "type": "string",
                                "description": "Amount being transferred or involved in a transaction",
                                "example": "10"
                              },
                              "data": {
                                "oneOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                ],
                                "description": "Main payload object or array returned by the API",
                                "example": "0x40e53eb7000000000000000000000000000000000000000000000000000000000016e360"
                              },
                              "gasPrice": {
                                "type": "string",
                                "description": "Price per gas unit for the transaction",
                                "example": "10000"
                              },
                              "referenceId": {
                                "type": "string",
                                "description": "Unique ID for tracking a specific transaction or operation",
                                "example": "8eec8150896e4fdaa26d4d1a1338d676"
                              },
                              "message": {
                                "type": "string",
                                "description": "Message string related to an operation"
                              },
                              "simulate": {
                                "type": "object",
                                "description": "Present when the request used `simulate: true`; eth_simulateV1 summary (omitted when simulation was not run).",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": [
                                      "success",
                                      "failure"
                                    ]
                                  },
                                  "error": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Failure reason when status is failure; null when status is success"
                                  }
                                },
                                "required": [
                                  "status",
                                  "error"
                                ]
                              }
                            },
                            "required": [
                              "chainId",
                              "from",
                              "to",
                              "value",
                              "data",
                              "referenceId"
                            ]
                          }
                        },
                        {
                          "type": "object",
                          "not": {
                            "required": [
                              "calls"
                            ]
                          },
                          "properties": {
                            "chainId": {
                              "type": "string",
                              "description": "Blockchain network identifier (EVM chain ID, Solana chain name, etc.)",
                              "example": "1"
                            },
                            "from": {
                              "type": "string",
                              "description": "Sender's wallet address",
                              "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                            },
                            "to": {
                              "type": "string",
                              "description": "Recipient's wallet address",
                              "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                            },
                            "gas": {
                              "type": "string",
                              "description": "Gas limit for the transaction",
                              "example": "100000"
                            },
                            "value": {
                              "type": "string",
                              "description": "Amount being transferred or involved in a transaction",
                              "example": "10"
                            },
                            "data": {
                              "oneOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              ],
                              "description": "Main payload object or array returned by the API",
                              "example": "0x40e53eb7000000000000000000000000000000000000000000000000000000000016e360"
                            },
                            "gasPrice": {
                              "type": "string",
                              "description": "Price per gas unit for the transaction",
                              "example": "10000"
                            },
                            "referenceId": {
                              "type": "string",
                              "description": "Unique ID for tracking a specific transaction or operation",
                              "example": "8eec8150896e4fdaa26d4d1a1338d676"
                            },
                            "message": {
                              "type": "string",
                              "description": "Message string related to an operation"
                            },
                            "simulate": {
                              "type": "object",
                              "description": "Present when the request used `simulate: true`; eth_simulateV1 summary (omitted when simulation was not run).",
                              "properties": {
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "success",
                                    "failure"
                                  ]
                                },
                                "error": {
                                  "type": "string",
                                  "nullable": true,
                                  "description": "Failure reason when status is failure; null when status is success"
                                }
                              },
                              "required": [
                                "status",
                                "error"
                              ]
                            }
                          },
                          "required": [
                            "referenceId"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "createFeeTxn": {
                              "type": "object",
                              "properties": {
                                "chainId": {
                                  "type": "string",
                                  "description": "Blockchain network identifier (EVM chain ID, Solana chain name, etc.)",
                                  "example": "1"
                                },
                                "from": {
                                  "type": "string",
                                  "description": "Sender's wallet address",
                                  "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                                },
                                "to": {
                                  "type": "string",
                                  "description": "Recipient's wallet address",
                                  "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                                },
                                "value": {
                                  "type": "string",
                                  "description": "Amount being transferred or involved in a transaction",
                                  "example": "10"
                                },
                                "gasPrice": {
                                  "type": "string",
                                  "description": "Price per gas unit for the transaction",
                                  "example": "10000"
                                },
                                "gas": {
                                  "type": "string",
                                  "description": "Gas limit for the transaction",
                                  "example": "100000"
                                },
                                "simulate": {
                                  "type": "object",
                                  "description": "Present when the request used `simulate: true` with `enableFee: true`; fee leg eth_simulateV1 summary.",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": [
                                        "success",
                                        "failure"
                                      ]
                                    },
                                    "error": {
                                      "type": "string",
                                      "nullable": true,
                                      "description": "Failure reason when status is failure; null when status is success"
                                    }
                                  },
                                  "required": [
                                    "status",
                                    "error"
                                  ]
                                }
                              },
                              "required": [
                                "chainId",
                                "from",
                                "to"
                              ]
                            },
                            "swapWithApproveTxn": {
                              "oneOf": [
                                {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "chainId": {
                                        "type": "string",
                                        "description": "Blockchain network identifier (EVM chain ID, Solana chain name, etc.)",
                                        "example": "1"
                                      },
                                      "from": {
                                        "type": "string",
                                        "description": "Sender's wallet address",
                                        "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                                      },
                                      "to": {
                                        "type": "string",
                                        "description": "Recipient's wallet address",
                                        "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                                      },
                                      "gas": {
                                        "type": "string",
                                        "description": "Gas limit for the transaction",
                                        "example": "100000"
                                      },
                                      "value": {
                                        "type": "string",
                                        "description": "Amount being transferred or involved in a transaction",
                                        "example": "10"
                                      },
                                      "data": {
                                        "oneOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        ],
                                        "description": "Main payload object or array returned by the API",
                                        "example": "0x40e53eb7000000000000000000000000000000000000000000000000000000000016e360"
                                      },
                                      "gasPrice": {
                                        "type": "string",
                                        "description": "Price per gas unit for the transaction",
                                        "example": "10000"
                                      },
                                      "referenceId": {
                                        "type": "string",
                                        "description": "Unique ID for tracking a specific transaction or operation",
                                        "example": "8eec8150896e4fdaa26d4d1a1338d676"
                                      },
                                      "message": {
                                        "type": "string",
                                        "description": "Message string related to an operation"
                                      },
                                      "simulate": {
                                        "type": "object",
                                        "description": "Present when the request used `simulate: true`; eth_simulateV1 summary (omitted when simulation was not run).",
                                        "properties": {
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "success",
                                              "failure"
                                            ]
                                          },
                                          "error": {
                                            "type": "string",
                                            "nullable": true,
                                            "description": "Failure reason when status is failure; null when status is success"
                                          }
                                        },
                                        "required": [
                                          "status",
                                          "error"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "chainId",
                                      "from",
                                      "to",
                                      "value",
                                      "data",
                                      "referenceId"
                                    ]
                                  }
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "chainId": {
                                      "type": "string",
                                      "description": "Blockchain network identifier (EVM chain ID, Solana chain name, etc.)",
                                      "example": "1"
                                    },
                                    "from": {
                                      "type": "string",
                                      "description": "Sender's wallet address",
                                      "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                                    },
                                    "to": {
                                      "type": "string",
                                      "description": "Recipient's wallet address",
                                      "example": "0xdAe2F6EdDdA6fb4fb60cc02633DE27e2b431B402"
                                    },
                                    "gas": {
                                      "type": "string",
                                      "description": "Gas limit for the transaction",
                                      "example": "100000"
                                    },
                                    "value": {
                                      "type": "string",
                                      "description": "Amount being transferred or involved in a transaction",
                                      "example": "10"
                                    },
                                    "data": {
                                      "oneOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        }
                                      ],
                                      "description": "Main payload object or array returned by the API",
                                      "example": "0x40e53eb7000000000000000000000000000000000000000000000000000000000016e360"
                                    },
                                    "gasPrice": {
                                      "type": "string",
                                      "description": "Price per gas unit for the transaction",
                                      "example": "10000"
                                    },
                                    "referenceId": {
                                      "type": "string",
                                      "description": "Unique ID for tracking a specific transaction or operation",
                                      "example": "8eec8150896e4fdaa26d4d1a1338d676"
                                    },
                                    "message": {
                                      "type": "string",
                                      "description": "Message string related to an operation"
                                    },
                                    "simulate": {
                                      "type": "object",
                                      "description": "Present when the request used `simulate: true`; eth_simulateV1 summary (omitted when simulation was not run).",
                                      "properties": {
                                        "status": {
                                          "type": "string",
                                          "enum": [
                                            "success",
                                            "failure"
                                          ]
                                        },
                                        "error": {
                                          "type": "string",
                                          "nullable": true,
                                          "description": "Failure reason when status is failure; null when status is success"
                                        }
                                      },
                                      "required": [
                                        "status",
                                        "error"
                                      ]
                                    }
                                  },
                                  "required": [
                                    "referenceId"
                                  ]
                                }
                              ]
                            }
                          },
                          "required": [
                            "createFeeTxn",
                            "swapWithApproveTxn"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "from": {
                              "type": "string"
                            },
                            "chainId": {
                              "type": "string"
                            },
                            "referenceId": {
                              "type": "string"
                            },
                            "methodUsed": {
                              "type": "string",
                              "enum": [
                                "EIP-5792",
                                "EIP-7702"
                              ]
                            },
                            "calls": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "to": {
                                    "type": "string"
                                  },
                                  "value": {
                                    "type": "string"
                                  },
                                  "data": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "to",
                                  "value",
                                  "data"
                                ]
                              }
                            }
                          },
                          "required": [
                            "from",
                            "chainId",
                            "referenceId",
                            "methodUsed",
                            "calls"
                          ]
                        }
                      ]
                    }
                  },
                  "example": {
                    "status": 200,
                    "msg": "success",
                    "data": [
                      {
                        "chainId": "1",
                        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
                        "to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
                        "value": "0",
                        "gas": "173376",
                        "data": "0x095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d00000000000000000000000000000000000000000000000000038d7ea4c68000",
                        "nonce": 0,
                        "referenceId": "497ef8cb1f224ab3ac8ee68211237298"
                      },
                      {
                        "chainId": "1",
                        "from": "0x63056E00436Da25BcF48A40dfBbDcc7089351006",
                        "to": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
                        "value": "0",
                        "gas": "173376",
                        "data": "0x38ed173900000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000063056e00436da25bcf48a40dfbbdcc708935100600000000000000000000000000000000000000000000000000000000634d00ee0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f",
                        "nonce": 1,
                        "referenceId": "497ef8cb1f224ab3ac8ee68211237298"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "x-bd-cu": "85",
        "x-bd-cu-type": "fixed",
        "x-internal": false
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```