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

# Generate Approve Transaction

> Generate the transaction data needed to approve the AKKA Router to spend a token on your behalf. Returns encoded calldata that must be signed and submitted to the blockchain. If no amount is specified, unlimited approval is granted.

## Unlimited vs. specific approval

* **Omit `amount`**: Grants unlimited approval. The AKKA Router can spend any amount of this token. Recommended for frequent swapping — you only need to approve once.
* **Set `amount`**: Grants approval for exactly this many tokens (in wei). More secure, but requires a new approval transaction each time the allowance is consumed.

## Using the response

Sign and submit the returned transaction object to the blockchain:

```javascript theme={null}
const hash = await walletClient.sendTransaction({
  to: approveTx.to,     // Token contract address
  data: approveTx.data,  // Encoded approve() calldata
  value: BigInt(approveTx.value), // Always "0"
});

await publicClient.waitForTransactionReceipt({ hash });
```

<Warning>
  Wait for the approval transaction to be confirmed before calling the swap endpoint.
</Warning>


## OpenAPI

````yaml GET /swap/v1/{chainId}/approve/transaction
openapi: 3.0.3
info:
  title: AKKA Finance API
  version: 1.0.0
  description: >-
    AKKA Finance liquidity aggregation API. Find the best swap routes across
    multiple DEXes and execute token swaps with optimal pricing.
  contact:
    name: AKKA Finance
    url: https://akka.finance
    email: support@akka.finance
servers:
  - url: https://api.akka.finance
    description: Production
security:
  - apiKey: []
paths:
  /swap/v1/{chainId}/approve/transaction:
    get:
      tags:
        - Approvals
      summary: Generate approve transaction data
      description: >-
        Generate the transaction data needed to approve the AKKA Router to spend
        a token on your behalf. Returns encoded calldata that must be signed and
        submitted to the blockchain. If no amount is specified, unlimited
        approval is granted.
      operationId: getApproveTransaction
      parameters:
        - name: chainId
          in: path
          required: true
          description: Blockchain chain ID
          schema:
            type: integer
            enum:
              - 999
            example: 999
        - name: tokenAddress
          in: query
          required: true
          description: Contract address of the token to approve.
          schema:
            type: string
            pattern: ^0x[a-fA-F0-9]{40}$
            example: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb'
        - name: amount
          in: query
          required: false
          description: >-
            Number of tokens to approve (in wei). If omitted, unlimited approval
            is granted (`type(uint256).max`).
          schema:
            type: string
            example: '1000000000000000000'
      responses:
        '200':
          description: Approve transaction data generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApproveTransactionResponse'
              example:
                data: >-
                  0x095ea7b3000000000000000000000000cce7452db4392b40aa0e1592a7c486e13bf69654ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
                gasPrice: '100000000'
                to: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb'
                value: '0'
        '400':
          description: Bad request — invalid address or token not found on chain
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ApproveTransactionResponse:
      type: object
      required:
        - data
        - gasPrice
        - to
        - value
      properties:
        data:
          type: string
          description: Encoded ERC-20 `approve()` calldata
          example: 0x095ea7b3...
        gasPrice:
          type: string
          description: Gas price in wei
          example: '100000000'
        to:
          type: string
          description: Token contract address (send the approval tx to this address)
          example: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb'
        value:
          type: string
          description: Always `"0"` for approve transactions
          example: '0'
    ErrorResponse:
      type: object
      required:
        - statusCode
        - message
        - error
        - timestamp
        - path
      properties:
        statusCode:
          type: integer
          description: HTTP status code
          example: 400
        message:
          type: string
          description: Human-readable error description
          example: No route found for the given token pair
        error:
          type: string
          description: Error type
          example: Bad Request
        timestamp:
          type: string
          format: date-time
          description: When the error occurred
          example: '2025-01-15T12:00:00.000Z'
        path:
          type: string
          description: API endpoint path that produced the error
          example: /swap/v1/999/quote
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: apikey
      description: API key for authentication. Contact AKKA on Telegram to obtain your key.

````