# Swapping Tokens

{% hint style="info" %}
Swaps are performed through the [0x Protocol](https://0x.org/docs/) aggregator which will automatically give you the most optimal swap rate across DEXes.
{% endhint %}

### Prerequisites

* You have either [created](https://terminalwallet-cli.gitbook.io/terminal-wallet/first-time-setup/creating-a-new-wallet) or [imported](https://terminalwallet-cli.gitbook.io/terminal-wallet/first-time-setup/import-an-existing-wallet) a wallet
* Funds shielded into a 0zk address: [shielding-assets](https://terminalwallet-cli.gitbook.io/terminal-wallet/transactions/shielding-assets "mention")

### Swapping Walkthrough

#### 1. Navigate to 'Swap' functions and press Enter. Press Enter again to select tokens and amount.&#x20;

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FmMKJlBVaHjT2zwESElVr%2F1%20main%20screen%20-%20highlight%20button.png?alt=media&#x26;token=176dc42e-9143-4ea5-916f-658b404b8f73" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FsMmtpzgoQK6ovdqiervZ%2F2.png?alt=media&#x26;token=e55ab1fa-b5e8-4c74-acea-aae54f1311a2" alt=""><figcaption><p>Press Enter here to proceed</p></figcaption></figure>

You can also swap assets held in your public 0x address by pressing Enter on 'Publicly SWAP ERC20 Tokens'. The process is much the same except you will need some amount of network base token held in the 0x address to pay for gas.

#### 2. Navigate to the token you want to send. Press space to select and press Enter to confirm

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FHG8PssrZZtfIGgAyQOXw%2F3%20select%20send%20token.png?alt=media&#x26;token=89315ba0-d998-4ba8-95a3-7abeb107a90d" alt=""><figcaption></figcaption></figure>

#### 3. Enter the amount to unshield and press Enter

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FGKdAH3SVBBQZksLMvE5e%2F4%20select%20amount%20to%20transact.%20max%20filled%20automaticly.png?alt=media&#x26;token=4d9377f1-3e44-43c4-88e1-f6556506ed13" alt=""><figcaption></figcaption></figure>

The maximum amount is pre-filled. If you press enter without entering in any values, it will automatically proceed with the maximum possible balance.

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FauZTrCiBe0Ht0rtOCI2I%2F5%20entered%20custom%20amount.png?alt=media&#x26;token=4aa7d34c-3aa7-4d78-9dec-2f0c365384ab" alt=""><figcaption><p>Swap screen with a custom amount</p></figcaption></figure>

#### 4. Select a token to swap into from the list and proceed to step 6 OR press Enter on 'Add Token' to add a custom token

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2Fpu6nIHEy1JRdtRwKt1hv%2F6%20select%20recieve%20token.%20add%20token%20selected.png?alt=media&#x26;token=4ec93cb6-c078-4504-b68c-a2998146bca9" alt=""><figcaption></figcaption></figure>

Paste in the token contract address if adding in a custom token.&#x20;

> **Always double check token addresses to ensure they are the correct token. Anyone can deploy a token with any name.**

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FKNniogN3VMa7kGbx3STP%2F7.%20custom%20swap%20token%2C%20WBTC%20for%20example.png?alt=media&#x26;token=6fc59672-85f6-4db2-87b5-7f5b02d39361" alt=""><figcaption><p>Swap screen with custom token address</p></figcaption></figure>

#### 5. If you added a custom token, press Enter on the token from the list

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FVqrjJd0tM2YmM9P0Ru4h%2F8%20select%20WBTC.png?alt=media&#x26;token=5f4e5315-d6e2-4ce9-b23a-cccc0503633b" alt=""><figcaption></figcaption></figure>

#### 6. Review the swap transaction details closely including amount, tokens, and swap rates. Press Enter on 'Confirm Transaction Amounts

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2F5S2jvNtjUF3nJWys9U89%2F9%20review%2C%20confirm%2C%20enter%20password.png?alt=media&#x26;token=3076f95c-4a2c-42c8-a924-8484ecbc0591" alt=""><figcaption></figcaption></figure>

#### 7. Type in your Terminal Wallet password

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FyOrKNC04SgfxTzzunwr4%2Fimage.png?alt=media&#x26;token=ff1738a7-6175-4a03-a9e9-889a445a681d" alt=""><figcaption></figcaption></figure>

#### 8. Press Enter to select a Relayer

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FPicmDQ3xODPeRPiEdVWD%2F10%20relay%20or%20self%20sign.png?alt=media&#x26;token=59b73d2c-521a-4297-b752-7f6d6dacc56b" alt=""><figcaption></figcaption></figure>

Relayers are wallets which submit transactions on your behalf so that your 0x address is not exposed when transacting. You can either use a community run Relayer or [Self-Relay](https://terminalwallet-cli.gitbook.io/terminal-wallet/transactions/self-relaying-transactions) a transaction.

{% embed url="<https://docs.railgun.org/wiki/learn/privacy-system/community-relayers>" %}

#### 9. Press Enter on 'Use a Relayer' to use a community Relayer

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FGqXLF56mpzfTm4bk1aVS%2Fimage.png?alt=media&#x26;token=212fe45e-270a-4ab3-8bbb-a116df58f4f0" alt=""><figcaption></figcaption></figure>

#### 10. Select token to pay the Relayer

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2F8Qnz5FwgIdcp6WsAGcnQ%2Fimage.png?alt=media&#x26;token=62f3c9f4-a846-454f-80ea-384d78f02bf6" alt=""><figcaption></figcaption></figure>

Most community Relayers will accept wrapped base token like WETH or WMATIC and stablecoins like DAI or USDC.

#### 10. Review the 'Network Fee' closely. Press Enter on 'Generate Proof' to proceed

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FEtDaLne36qtqQLhD3gRk%2F11%20review%20and%20generate%20proof.png?alt=media&#x26;token=492e4340-e43e-4b1b-8f84-c215a4e91a33" alt=""><figcaption></figcaption></figure>

This will generate a Zero Knowledge Proof which enables to prove your capacity to complete the transaction privately. Proof generation can take up to 30 seconds depending on your hardware.

{% embed url="<https://docs.railgun.org/wiki/learn/privacy-system/zero-knowledge-cryptography>" %}

#### 11. Review transaction details closely and Press Enter on 'Send Transaction' if correct

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2F3HRTm2qsRkc2bqtDULWD%2F12%20review%20and%20send.png?alt=media&#x26;token=bed6ba4c-174e-4263-8f13-0e38a4c98edf" alt=""><figcaption></figcaption></figure>

After this, the transaction cannot be changed and the assets will be unshielded to the destination 0x address so ensure that details are correct.

#### 12. Wait for transaction confirmation&#x20;

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2FBIPZCFqZ15UwnbIymXla%2F13%20sending%20waiting%20screen.png?alt=media&#x26;token=40857e86-b782-45e8-9ad1-ce564c5c8309" alt=""><figcaption></figcaption></figure>

#### 13. Swap is completed and new balances are updated

<figure><img src="https://2690606389-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPL8GddQ0x75dvPhyXUkK%2Fuploads%2Fay3NLc7cJTmt9n6queXT%2F16%20updated%20balance.png?alt=media&#x26;token=734b05e1-0b2c-4ff1-9226-9c9ad47c208d" alt=""><figcaption></figcaption></figure>

The private swap has now been completed and your token balances are reflected in the [Main Balance Screen](https://terminalwallet-cli.gitbook.io/terminal-wallet/first-time-setup/main-balance-screen).
