# Step 3: Swap Tokens

## Swapping Tokens

### Step 3.1: Swap tokens

Enter the two tokens to swap from / to and enter the amount.

{% tabs %}
{% tab title="CLI" %}

```
Usage: rly-cli tbc-swap [options] <swap> <token_a> <token_b> <amount>

Arguments:
  swap                  swap
  token_a               token A
  token_b               token B
  amount                amount of token a to swap

Options:
  -e, --env <string>    Solana cluster env name (default: "devnet")
  -k, --keypair <path>  Solana wallet location (default: "--keypair not provided")
  -h, --help            display help for command
```

{% endtab %}

{% tab title="TS" %}

```
// token bonding curve

import { Provider } from "@project-serum/anchor"
import { Keypair, Connection, clusterApiUrl } from 'solana/web3js`;
import { tokenSwapProgram } from 'rly-js';

const walletKeyPair = Keypair.generate();
const provider = new Provider(new Connection(clusterApiUrl("devnet")), new NodeWallet(walletKeyPair), {});

const tokenSwap = await tokenSwapProgram(provider);

// 
```

Examples: <https://github.com/rally-dfs/dfs-ts/tree/main/ts/tests>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Use`tbc-swap-estimate` to see estimate outputs.&#x20;
{% endhint %}

## That's it!

In this section you should have:

* Swapped between two tokens in both directions
* Verified balance changes in both token swap token accounts
* Verified balance changes in the user token accounts


---

# 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://wiki.rly.network/rly-protocol/get-started/tbc-on-solana/step-3-swap-tokens.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.
