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

# Exchange from Credits

> Exchanges Based Credits tokens to the supported stablecoin tokens at 1:1 ratio and sends to specified recipient

<Note>
  This is a smart contract write function. The curl example shown is for illustration. To call this function, use web3 libraries (ethers.js, viem, web3.py) or JSON-RPC directly.
</Note>


## OpenAPI

````yaml POST /contracts/exchanger/exchangeFromCredits
openapi: 3.0.3
info:
  title: Based Exchanger Smart Contracts API
  description: >-
    OpenAPI specification for the Based Exchanger smart contracts system
    including the main Exchanger contract
  version: 1.0.0
  license:
    name: Proprietary
servers:
  - url: https://mainnet.base.org
    description: Base Mainnet (default RPC endpoint)
security: []
tags:
  - name: Exchange Operations
    description: Core token exchange functionality
  - name: Admin Operations
    description: Administrative functions requiring ADMIN_ROLE
  - name: Treasury Operations
    description: Treasury management functions requiring DEFAULT_ADMIN_ROLE
  - name: View Functions
    description: Read-only functions for querying contract state
  - name: Test Operations
    description: Functions available only in test contracts
paths:
  /contracts/exchanger/exchangeFromCredits:
    post:
      tags:
        - Exchange Operations
      summary: Exchange Based Credits to the supported stablecoin
      description: >-
        Exchanges Based Credits tokens to the supported stablecoin tokens at 1:1
        ratio and sends to specified recipient
      operationId: exchangeFromCredits
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExchangeFromCreditsRequest'
      responses:
        '200':
          description: Exchange successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionResponse'
        '400':
          description: >-
            Invalid request - amount cannot be zero, recipient cannot be zero
            address, or contract is paused
        '500':
          description: Transaction failed - insufficient balance or transfer failure
components:
  schemas:
    ExchangeFromCreditsRequest:
      type: object
      required:
        - amount
        - recipient
      properties:
        amount:
          type: string
          description: Amount of Based Credits to exchange (in wei/smallest unit)
          example: '1000000000000000000'
        recipient:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
          description: Address to receive the supported stablecoin
          example: '0x0000000000000000000000000000000000000000'
    TransactionResponse:
      type: object
      properties:
        transactionHash:
          type: string
          pattern: ^0x[a-fA-F0-9]{64}$
          description: Transaction hash
          example: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
        blockNumber:
          type: integer
          description: Block number where transaction was mined
          example: 12345678
        gasUsed:
          type: string
          description: Gas used for the transaction
          example: '21000'
        events:
          type: array
          items:
            $ref: '#/components/schemas/Event'
    Event:
      type: object
      properties:
        name:
          type: string
          description: Event name
        args:
          type: object
          description: Event arguments
          additionalProperties: true

````