# ChainAISwap's Cross Chain Swap Architecture

{% stepper %}
{% step %}

### 1 — Approve tokens on the source blockchain

The user is first asked to approve the tokens to send from the source blockchain. Approving tells the token smart contract that you allow the swap smart contract to use your tokens for the transfer.
{% endstep %}

{% step %}

### 2 — Select blockchains and tokens

* Select the source blockchain and the receiving (target) blockchain for the cross-chain swap.
* Select or input the token contract on the source blockchain.
* Input the desired token on the receiving blockchain.

You'll then see a simulation showing token values and fees for the transfer.
{% endstep %}

{% step %}

### 3 — Start the swap

* After reviewing the simulation, select "SWAP" to begin the cross-chain transaction.
  {% endstep %}

{% step %}

### 4 — Execute sendMessagePayFirstStep()

Once tokens are approved, the DApp prompts for another transaction that executes the function `sendMessagePayFirstStep()`. This function receives all necessary data so the smart contract can execute the swap.

As the swap commences you can track the transaction on Chainlink's CCIP portal (<https://ccip.chain.link/>). The DApp will generate that tracking link for you.
{% endstep %}

{% step %}

### 5 — Chainlink CCIP transfer

After the message is received on the source blockchain, it enters Chainlink's CCIP transfer system and is transmitted to the other blockchain. This process currently takes roughly 15–25 minutes due to Chainlink’s high security guarantees. As CCIP evolves (e.g., single-block transactions), this time is expected to decrease.
{% endstep %}

{% step %}

### 6 — Intermediate USDC swap via Circle CCTP

During the transaction, funds are swapped to USDC using Circle's Cross Chain Transfer Protocol (CCTP) as a medium to move value between chains. USDC is used as the intermediary because of its security and broad availability across implemented blockchains.

* After the cross-chain transfer completes through Circle's CCTP, the user receives USDC on the target blockchain.
* That USDC is then swapped into the target token and delivered to the user.

If the user chooses to send USDC directly on the source or target blockchain, the transaction is cheaper because it avoids extra swaps and some gas fees.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
Future improvements: additional direct routes will be implemented so users can transfer different tokens directly (without swapping to USDC first), which will lower fees.
{% endhint %}

{% hint style="info" %}
Listing & direct trade links: Communities can apply to be directly listed on ChainAISwap and can share a direct buy link that preloads their contract when accessed.
{% endhint %}

Link to Chainlink CCIP portal: <https://ccip.chain.link/>

Last updated 5 months ago.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chainaiswap.gitbook.io/chainaiswap-docs/near-instant-cross-chain-swapso/chainaiswaps-cross-chain-swap-architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
