---
name: moonpay-swap-tokens
description: Swap tokens on the same chain or bridge tokens across chains. Use when the user wants to swap, bridge, or move tokens.
tags: [trading]
---

# Swap or bridge tokens

## Goal

Swap tokens on the same chain, or bridge tokens across chains. Two commands:

- **`mp token swap`** — same chain, different tokens
- **`mp token bridge`** — cross chain

Both build via swaps.xyz, sign locally, broadcast, and register for tracking.

## Commands

### Swap (same chain)

```bash
mp token swap \
  --wallet <wallet-name> \
  --chain <chain> \
  --from-token <token-address> \
  --from-amount <amount> \
  --to-token <token-address>
```

Supports exact-out: use `--to-amount` instead of `--from-amount`.

### Bridge (cross chain)

```bash
mp token bridge \
  --from-wallet <wallet-name> \
  --from-chain <chain> \
  --from-token <token-address> \
  --from-amount <amount> \
  --to-chain <chain> \
  --to-token <token-address> \
  --to-wallet <wallet-name>  # optional, defaults to from-wallet
```

Supports exact-out: use `--to-amount` instead of `--from-amount`.

## Examples

### Same-chain swap (SOL → USDC on Solana)

```bash
mp token swap \
  --wallet main --chain solana \
  --from-token So11111111111111111111111111111111111111111 \
  --from-amount 0.1 \
  --to-token EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
```

### Cross-chain bridge (ETH → USDC.e on Polygon)

```bash
mp token bridge \
  --from-wallet funded --from-chain ethereum \
  --from-token 0x0000000000000000000000000000000000000000 \
  --from-amount 0.003 \
  --to-chain polygon \
  --to-token 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
```

### ERC20 swap (auto-approves if needed)

```bash
mp token swap \
  --wallet funded --chain polygon \
  --from-token 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 \
  --from-amount 5 \
  --to-token 0x0000000000000000000000000000000000000000
```

## Supported chains

solana, ethereum, base, polygon, arbitrum, optimism, bnb, avalanche, bitcoin (bridges only)

## How it works

1. Resolves wallet name → address
2. Builds unsigned transaction via swaps.xyz (handles decimal conversion)
3. If ERC20 token needs approval, sends an approve transaction first, then re-builds
4. Signs locally — private key never leaves the machine
5. Broadcasts to the network
6. Registers for tracking

`token swap` calls `token bridge` under the hood with `from-chain` = `to-chain`.

## Tips

- If the user provides token names/symbols, resolve to addresses with `mp token search --query "USDC" --chain solana`
- Check balances first with `mp token balance list --wallet <address> --chain <chain>`
- Native tokens use `0x0000000000000000000000000000000000000000` (EVM) or `So11111111111111111111111111111111111111111` (Solana)

## Related skills

- **moonpay-discover-tokens** — Search for token addresses
- **moonpay-check-wallet** — Check balances before swapping
- **moonpay-auth** — Set up wallets for signing


---
Source attribution: jiayaoqijia
Original project: https://github.com/jiayaoqijia/cryptoskill/blob/bcc0d208deaa4f1f80aa0df7ca26c4bed6318918/skills/payments/moonpay-official-moonpay-swap-tokens/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 MoonPay, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: jiayaoqijia
Original project: https://github.com/jiayaoqijia/cryptoskill/blob/bcc0d208deaa4f1f80aa0df7ca26c4bed6318918/skills/payments/moonpay-official-moonpay-swap-tokens/SKILL.md
Attribution basis: Source repository record

Fields of work: Marketing, Sales
Roles: Growth Marketer, Product Marketer, Sales Engineer
Specialties: API
Tools: Swaps.Xyz
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 38b1ce5aff85f1ead90f26bb2df480fb7fbd0e0ae5c706291b643dd50bf37c7a
