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

# Build Swap Calls

> Get transaction calls to execute a swap

## Overview

Returns transaction calls needed to execute a swap based on a quote. You execute these calls with your account/wallet to complete the swap on-chain.

## Request

<ParamField body="quoteId" type="string" required>
  Unique quote identifier (UUID) from the `/quotes` endpoint
</ParamField>

<ParamField body="takerAddress" type="string">
  Address executing the swap (optional if provided during quote request)
</ParamField>

<ParamField body="slippage" type="number" required>
  Maximum acceptable slippage (range: 0-1, e.g., 0.01 for 1%, default: 0.05 for 5%)
</ParamField>

<ParamField body="includeApprove" type="boolean" required>
  If true, response includes approve call if necessary
</ParamField>

## Response

<ResponseField name="chainId" type="string">
  Network identifier (e.g., "0x534e5f4d41494e")
</ResponseField>

<ResponseField name="calls" type="array" required>
  Transaction calls to execute

  <Expandable title="Call Object">
    <ResponseField name="contractAddress" type="string">
      Contract address to call
    </ResponseField>

    <ResponseField name="entrypoint" type="string">
      Function name to invoke
    </ResponseField>

    <ResponseField name="calldata" type="array">
      Call data (array of strings)
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://starknet.api.avnu.fi/swap/v3/build" \
    -H "Content-Type: application/json" \
    -d '{
      "quoteId": "0a5e3c8e-b5d2-4f1a-9c3d-7e6f5a4b3c2d",
      "takerAddress": "0x0123...abc",
      "slippage": 0.01,
      "includeApprove": true
    }'
  ```

  ```typescript TypeScript theme={null}
  // Step 1: Get quote
  const params = new URLSearchParams({
    sellTokenAddress: '0x049d...',
    buyTokenAddress: '0x053c...',
    sellAmount: '1000000000000000000',
    takerAddress: account.address
  });

  const quoteResponse = await fetch(
    `https://starknet.api.avnu.fi/swap/v3/quotes?${params}`
  );

  const quotes = await quoteResponse.json();
  const quote = quotes[0];

  // Step 2: Get execution calls
  const executeResponse = await fetch('https://starknet.api.avnu.fi/swap/v3/build', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      quoteId: quote.quoteId,
      takerAddress: account.address,
      slippage: 0.01,
      includeApprove: true
    })
  });

  const { calls } = await executeResponse.json();

  // Step 3: Execute transaction
  const tx = await account.execute(calls);
  await account.waitForTransaction(tx.transaction_hash);

  console.log(`Swap complete: ${tx.transaction_hash}`);
  ```

  ```python Python theme={null}
  import requests
  from starknet_py.net.account.account import Account

  # Step 1: Get quote
  params = {
      'sellTokenAddress': '0x049d...',
      'buyTokenAddress': '0x053c...',
      'sellAmount': '1000000000000000000',
      'takerAddress': account.address
  }

  quote_response = requests.get(
      'https://starknet.api.avnu.fi/swap/v3/quotes',
      params=params,
  )

  quotes = quote_response.json()
  quote = quotes[0]

  # Step 2: Get execution calls
  execute_response = requests.post(
      'https://starknet.api.avnu.fi/swap/v3/build',
      json={
          'quoteId': quote['quoteId'],
          'takerAddress': account.address,
          'slippage': 0.01,
          'includeApprove': True
      },
  )

  calls = execute_response.json()['calls']

  # Step 3: Execute transaction
  tx = await account.execute(calls)
  print(f"Swap complete: {tx.transaction_hash}")
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "chainId": "0x534e5f4d41494e",
    "calls": [
      {
        "contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
        "entrypoint": "approve",
        "calldata": ["0x123...", "1000000000000000000", "0"]
      },
      {
        "contractAddress": "0x123abc...",
        "entrypoint": "swap",
        "calldata": ["0x049d...", "0x053c...", "1000000000000000000", "3150000000", "0"]
      }
    ]
  }
  ```
</ResponseExample>
