> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hypermid.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute Swap

> Get transaction data for a swap

Returns the transaction data for a swap. Sign it with the user's wallet and broadcast it.

<ParamField body="fromChain" type="number" required>
  Source chain ID (e.g., `1` for Ethereum, `8453` for Base, `369` for PulseChain).
</ParamField>

<ParamField body="toChain" type="number" required>
  Destination chain ID.
</ParamField>

<ParamField body="fromToken" type="string" required>
  Source token contract address. Use `0x0000000000000000000000000000000000000000` for native tokens (ETH, PLS, etc.).
</ParamField>

<ParamField body="toToken" type="string" required>
  Destination token contract address.
</ParamField>

<ParamField body="fromAmount" type="string" required>
  Amount in the smallest unit (e.g., wei). Must be a string to handle large numbers.
</ParamField>

<ParamField body="fromAddress" type="string" required>
  Sender wallet address.
</ParamField>

<ParamField body="toAddress" type="string" required>
  Recipient wallet address on the destination chain.
</ParamField>

<ParamField body="slippage" type="number">
  Maximum slippage as a decimal (e.g., `0.03` for 3%). Default: `0.03`.
</ParamField>

<ParamField body="tool" type="string">
  Specific routing tool. Omit to let Hypermid choose the best automatically.
</ParamField>

<ParamField body="depositMode" type="string">
  Set to `"manual"` to force manual deposit flow for non-EVM chains.
</ParamField>

## Response Types

The response has one of two shapes depending on the route:

### Transaction Request (most swaps)

Sign it and broadcast.

```typescript theme={"system"}
const tx = await wallet.sendTransaction(exec.data.transactionRequest);
```

<Tip>
  **ERC20 input?** Approve `estimate.approvalAddress` (not `transactionRequest.to`)
  first. On wallets that support **EIP-7702 / EIP-5792** you can collapse the
  approval and the swap into a single tap — see the
  [1-Tap Approve + Swap guide](/guides/batched-approval).
</Tip>

### Deposit Address (XRP, Dogecoin, Stellar, etc.)

Show the address to the user. They send tokens from their native wallet.

```typescript theme={"system"}
console.log("Send to:", exec.data.depositAddress);
console.log("Memo:", exec.data.memo); // Required for XRP, Stellar
```

Track deposit-based swaps with [`GET /v1/execute/deposit/status`](/api-reference/deposit-status).

<Tip>
  **Some PulseChain routes** require a confirmation step after the transaction. If the quote response includes `afterStep1`, see [Register — Inbound Receiver](/api-reference/register-inbound-receiver).
</Tip>

<ResponseExample>
  ```json 200 Transaction Request theme={"system"}
  {
    "data": {
      "transactionRequest": {
        "to": "0xContractAddress",
        "data": "0x2646478b...",
        "value": "1000000000000000000",
        "gasLimit": "350000",
        "chainId": 1
      },
      "estimate": {
        "fromAmount": "1000000000000000000",
        "fromAmountUSD": "3250.00",
        "toAmount": "3237500000",
        "toAmountUSD": "3237.50",
        "executionDuration": 120
      }
    }
  }
  ```

  ```json 200 Deposit Address theme={"system"}
  {
    "data": {
      "depositId": "dep_abc123def456",
      "depositAddress": "rDepositXRPAddress",
      "depositMode": "manual",
      "memo": "12345678",
      "transactionRequest": null,
      "estimate": {
        "fromAmount": "50000000",
        "toAmount": "120000000",
        "toAmountUSD": "120.00",
        "executionDuration": 180
      },
      "expiresAt": 1711235475
    }
  }
  ```
</ResponseExample>

<CodeGroup>
  ```typescript TypeScript theme={"system"}
  const exec = await client.execute({
    fromChain: 1,
    toChain: 42161,
    fromToken: "0x0000000000000000000000000000000000000000",
    toToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
    fromAmount: "1000000000000000000",
    fromAddress: "0xYourAddress",
    toAddress: "0xYourAddress",
    slippage: 0.03,
  });

  if (exec.data.transactionRequest) {
    const tx = await wallet.sendTransaction(exec.data.transactionRequest);
    console.log("Tx hash:", tx.hash);
  } else if (exec.data.depositAddress) {
    console.log("Send to:", exec.data.depositAddress);
    if (exec.data.memo) console.log("Memo:", exec.data.memo);
  }
  ```

  ```bash cURL theme={"system"}
  curl -X POST "https://api.hypermid.io/v1/execute" \
    -H "Content-Type: application/json" \
    -H "X-API-Key: your-api-key" \
    -d '{
      "fromChain": 1,
      "toChain": 42161,
      "fromToken": "0x0000000000000000000000000000000000000000",
      "toToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
      "fromAmount": "1000000000000000000",
      "fromAddress": "0xYourAddress",
      "toAddress": "0xYourAddress",
      "slippage": 0.03
    }'
  ```
</CodeGroup>

<Warning>
  Transaction data is time-sensitive. Sign and broadcast within a few minutes — prices and gas estimates change.
</Warning>


## OpenAPI

````yaml POST /v1/execute
openapi: 3.0.3
info:
  title: Hypermid Partner API
  version: 1.0.0
  description: >-
    Cross-chain swap aggregator API. Supports 30+ EVM chains, Solana, Bitcoin,
    Sui, and Near Intents chains (NEAR, TON, Tron, XRP, etc.).


    ## Authentication

    Pass your API key via the `X-API-Key` header. Public endpoints work without
    a key (anonymous tier). Partner endpoints (`/v1/partner/*`) require a valid
    key.


    ## Rate Limits

    - **Anonymous**: 30 requests/minute (per IP)

    - **Partner (authenticated)**: 100 requests/minute (per API key)


    These limits are designed for human-driven widget usage and mirror our
    upstream aggregator (LiFi) limits to prevent any single user from exhausting
    shared quota.


    Rate limit info is returned in `meta.rateLimit` on every response.


    ## Response Envelope

    All responses follow the shape:

    ```json

    { "data": <T | null>, "error": <{ code, message, details? } | null>, "meta":
    { "requestId", "timestamp", "rateLimit?" } }

    ```
  contact:
    name: Hypermid
    url: https://hypermid.io
servers:
  - url: https://api.hypermid.io
    description: Production
security:
  - ApiKeyAuth: []
  - {}
tags:
  - name: Swap
    description: Cross-chain swap quoting, routing, status, and reference data
  - name: Execute
    description: Transaction execution and deposit management for Near Intents swaps
  - name: On-Ramp
    description: Fiat-to-crypto on-ramp via RampNow
  - name: Partner
    description: Partner account, analytics, and webhook management (requires X-API-Key)
  - name: Tracking
    description: Swap event tracking for partner attribution
  - name: System
    description: Health check and API metadata
paths:
  /v1/execute:
    post:
      tags:
        - Execute
      summary: Get transaction data for execution
      description: >-
        For Near Intents routes: returns a deposit address where the user should
        send tokens. For LI.FI routes, use GET /v1/quote with toAddress instead
        (the response already includes transactionRequest).


        **Near Intents flow:**

        1. POST /v1/execute to get depositAddress

        2. Send tokens to the depositAddress on-chain

        3. POST /v1/execute/deposit/submit with { txHash, depositAddress }

        4. Poll GET /v1/execute/deposit/status?depositAddress=... until
        completion
      operationId: executeSwap
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                fromChain:
                  type: integer
                  description: Source chain ID
                fromToken:
                  type: string
                  description: Source token address
                fromAmount:
                  type: string
                  description: Amount in base units
                toChain:
                  type: integer
                  description: Destination chain ID
                toToken:
                  type: string
                  description: Destination token address
                fromAddress:
                  type: string
                  description: Sender wallet address
                toAddress:
                  type: string
                  description: Recipient wallet address
                refundAddress:
                  type: string
                  description: Refund address (defaults to fromAddress)
                slippage:
                  type: number
                  description: Slippage tolerance (decimal or bps)
              required:
                - fromChain
                - fromToken
                - fromAmount
                - toChain
                - toToken
                - fromAddress
                - toAddress
      responses:
        '200':
          description: Execution data with deposit address
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          provider:
                            type: string
                            example: near-intents
                          depositAddress:
                            type: string
                            description: Address to send tokens to
                          depositMemo:
                            type: string
                            description: >-
                              Memo to include with the deposit (if required by
                              the chain)
                          expectedOutput:
                            type: string
                          expectedOutputUsd:
                            type: number
                          minAmountOut:
                            type: string
                          timeEstimate:
                            type: string
                          correlationId:
                            type: string
                          feeBps:
                            type: integer
                          instructions:
                            type: object
        '400':
          $ref: '#/components/responses/BadRequest'
        '502':
          $ref: '#/components/responses/UpstreamError'
        '504':
          description: Request timed out
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiResponse'
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        data:
          description: Response payload (null on error)
        error:
          nullable: true
          type: object
          properties:
            code:
              type: string
              example: INVALID_PARAMS
            message:
              type: string
              example: 'Missing required parameters: fromChain'
            details:
              type: object
              additionalProperties: true
          required:
            - code
            - message
        meta:
          $ref: '#/components/schemas/Meta'
      required:
        - data
        - error
        - meta
    Meta:
      type: object
      properties:
        requestId:
          type: string
          format: uuid
        timestamp:
          type: integer
          description: Unix epoch seconds
        rateLimit:
          type: object
          properties:
            limit:
              type: integer
            remaining:
              type: integer
            reset:
              type: integer
              description: Unix epoch seconds when the window resets
      required:
        - requestId
        - timestamp
  responses:
    BadRequest:
      description: Invalid or missing parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiResponse'
    UpstreamError:
      description: Upstream provider error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        Partner API key. Optional for public endpoints, required for
        /v1/partner/*.

````