# iFrame Initialization

### Required Parameters

* <mark style="color:red;">`apiKey`</mark>: Your publishable API key for customer identification and session validation. Also known as the public key. Can be found in the "**Developers**" section of the [swapped.com dashboard](https://dashboard.swapped.com/connect/developers).
* <mark style="color:red;">`walletAddress`</mark>: The crypto wallet where the user's funds will be sent. You can include one or more wallet entries, separated by commas. **Format to follow:** <mark style="color:blue;">`CURRENCY:NETWORK:ADDRESS:AMOUNT`</mark>
  * **CURRENCY** – token symbol (e.g., <mark style="color:blue;">`BTC`</mark>, <mark style="color:blue;">`SOL`</mark>, <mark style="color:blue;">`ETH`</mark>, <mark style="color:blue;">`USDT`</mark>)
  * **NETWORK** – on‑chain network identifier (e.g., <mark style="color:blue;">`bitcoin`</mark>, <mark style="color:blue;">`ethereum`</mark>, <mark style="color:blue;">`solana`</mark>)
  * **ADDRESS** – the on‑chain address itself (e.g., <mark style="color:blue;">`ltc1q2k0xaafhgt3s8qw03wmajjmlc8gcepdy0un0ah`</mark>)
  * **(OPTIONAL): AMOUNT** – the **minimum amount (in that token)** a user must send to the address. Can't be 0; decimals are supported.
* <mark style="color:red;">`signature`</mark>: A cryptographic signature to verify the authenticity of the request. See the [**Server-Side URL Signature**](#server-side-url-signature) section below for implementation details.

If using one address, it’ll look like this:\ <mark style="color:blue;">`walletAddress=LTC:litecoin:ltc1q2k0xaafhgt3s8qw03wmajjmlc8gcepdy0un0ah`</mark>

If you want to accept multiple currencies, for example, Bitcoin, Litecoin, and Ethereum, format the <mark style="color:red;">`walletAddress`</mark> parameter as follows:\ <mark style="color:blue;">`walletAddress=BTC:bitcoin:yourBitcoinAddress,LTC:litecoin:yourLitecoinAddress,ETH:ethereum:yourEthereumAddress`</mark>

To enforce a minimum transaction amount on a specific address, **add it as the final value**:\ <mark style="color:blue;">`walletAddress=LTC:litecoin:yourLitecoinAddress:5`</mark>

Examples:

* <mark style="color:blue;">`BTC:bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa:10`</mark> – Bitcoin address with a minimum of 10 BTC
* <mark style="color:blue;">`ETH:ethereum:0x742d35Cc6634C0532925a3b844Bc454e4438f44e:5`</mark> – Ethereum address with a minimum of 5 ETH
* <mark style="color:blue;">`ETH:ethereum:0x742d35Cc6634C0532925a3b844Bc454e4438f44e`</mark> – Ethereum address with no minimum amount

### Optional Parameters

* <mark style="color:red;">`baseCurrencyCode`</mark>: The FIAT currency code for transactions (e.g., USD, EUR, GBP). See [**Supported Fiat currencies**](https://docs.swapped.com/readme/iframe-initialization/supported-fiat-currencies) for more options.
* <mark style="color:red;">`connection`</mark>: The exchange platform or wallet to use (e.g., Binance, Coinbase, Kraken, Phantom, etc.). See [supported connections](/swapped-connect/connect-integration/supported-connections.md) for available platforms and wallets.
* <mark style="color:red;">`destinationTag`</mark>: Adds a numeric destination tag (XRP) or text memo (TON) to identify specific recipients or provide transaction context.
* <mark style="color:red;">`baseCountry`</mark>: (ISO) The country code for the user's location. If not provided, it will be detected automatically. See [supported countries](https://swapped.com/supported-countries) for more options.
* <mark style="color:red;">`webhookUrl`</mark>: To receive webhooks, you can specify a webhook URL through this parameter - it must be URLencoded (**e.g., https%3A%2F%2Fwww\.myurl.com**).&#x20;
* <mark style="color:red;">`payWalletAddress`</mark>: The crypto wallet where the user's funds will be sent for Exchange Pay products. Structure is the same as for required <mark style="color:red;">`walletAddress`</mark> parameter <mark style="color:blue;">`CURRENCY:NETWORK:ADDRESS:AMOUNT`</mark>, **e.g. USDC:solana:yourSolanaAddress,LTC:litecoin:yourLitecoinAddress:5**
* <mark style="color:red;">`externalCustomerId`</mark>: Your unique identifier for the customer.
* <mark style="color:red;">`preferredCurrencyToReceive`</mark>: The preferred currency to receive from Exchange Pay products. The user may still choose a different currency, however, if available, it will be displayed as the default currency in the initial selection screen. Structure is as follows: <mark style="color:blue;">`CURRENCY:NETWORK`</mark> **e.g. USDC:solana**
* <mark style="color:red;">`name`</mark>: Overrides the displayed merchant name in the Connect interface with a custom value. Must be URL-encoded (e.g., `My%20Store`)
* <mark style="color:red;">`logo`</mark>: A URL pointing to the merchant's logo to be displayed in the Connect interface. Must be a publicly accessible HTTPS URL and URL-encoded (e.g., `https%3A%2F%2Fexample.com%2Flogo.png`). Recommended formats: PNG or SVG.

### Server-Side URL Signature

Generate a signature to prevent the URL from being modified. This is done using the query string, including '?' and the secret key shared with you.

#### Example with NodeJS

{% code overflow="wrap" fullWidth="false" %}

```javascript
// Import the crypto module.
import crypto from 'crypto';

// Define the public API key.
const apiKey = 'your-api-key-12345';

// Define the secret API key.
const secretKey = 'your_secret_key';

// Define the wallet address.
const walletAddress = 'BTC:bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa:10';

// Build URL with query parameters.
const originalUrl = `https://connect.swapped.com/?apiKey=${apiKey}&walletAddress=${walletAddress}`;

// Create a SHA-256 HMAC signature from the URL's search string, then encode in Base64.
const signature = crypto.createHmac('sha256', secretKey).update(new URL(originalUrl).search).digest('base64');

// Append the URL-encoded signature to the original URL.
const urlWithSignature = `${originalUrl}&signature=${encodeURIComponent(signature)}`;

// Output the final URL with the signature appended.
console.log(urlWithSignature);
```

{% endcode %}

## Example with PHP

{% code overflow="wrap" fullWidth="false" %}

```php
<?php

// Define the public API key.
$apiKey = 'your-api-key-12345';

// Define the secret API key.
$secretKey = 'your_secret_key';

// Define the wallet address.
$walletAddress = 'BTC:bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa:10';

// Build URL with query parameters.
$originalUrl = "https://connect.swapped.com/?apiKey={$apiKey}&walletAddress={$walletAddress}";

// Parse the URL into its components.
$parsedUrl = parse_url($originalUrl);

// Create a SHA-256 HMAC signature from the query string, then encode in Base64.
$signature = base64_encode(hash_hmac('sha256', '?'.$parsedUrl['query'], $secretKey, true));

// Append the URL-encoded signature to the URL.
$urlWithSignature = "{$originalUrl}&signature=" . urlencode($signature);

// Output the final URL with the signature appended.
echo $urlWithSignature;
```

{% endcode %}

### Example iFrame URL

**Note: This is a test key, so your key will be different.**

<mark style="color:blue;">`https://connect.swapped.com/?apiKey=your-api-key-12345&walletAddress=BTC:bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa:10&signature=RyvwgGPnBBfP2VwKz1beHveU4%2BTjPIwRYNj0s6hKNVU%3D`</mark>

### Example iFrame

The iFrame has been optimized for height: 585px; width: 445px.

{% code overflow="wrap" fullWidth="false" %}

```html
<iframe
  allow="accelerometer; autoplay; camera; encrypted-media; gyroscope; payment; clipboard-read; clipboard-write"
  src="https://connect.swapped.com/?apiKey={your-api-key}&walletAddress=BTC:bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa:10&signature={your_signature}"
  title="Deposit with Swapped Connect"
  style="height: 585px; width: 445px; border-radius: 0.75rem; margin: auto;">
</iframe>
```

{% endcode %}

### Supported Networks

Below is a list of supported network identifiers — the values you supply in the [**NETWORK** ](#required-parameters)segment of your [`walletAddress` ](#required-parameters)parameter:

* Bitcoin: <mark style="color:red;">`bitcoin`</mark>
* Litecoin: <mark style="color:red;">`litecoin`</mark>
* Ethereum: <mark style="color:red;">`ethereum`</mark>
* Solana: <mark style="color:red;">`solana`</mark>
* Polygon: <mark style="color:red;">`polygon`</mark>
* Binance Smart Chain: <mark style="color:red;">`bsc`</mark>
* Ripple: <mark style="color:red;">`ripple`</mark>
* Base: <mark style="color:red;">`base`</mark>
* Tron: <mark style="color:red;">`tron`</mark>
* Avalanche: <mark style="color:red;">`avalanche`</mark>
* Arbitrum: <mark style="color:red;">`arb`</mark>
* Cronos: <mark style="color:red;">`cronos`</mark>
* Fantom: <mark style="color:red;">`fantom`</mark>
* Optimism: <mark style="color:red;">`optimism`</mark>

### Error Handling

The system will return an appropriate error message if an invalid signature or API key is provided.&#x20;

Common errors include:

* Unknown partner - The API key is not recognized
* Invalid signature - The signature does not match the expected value
* Partner '\[name]' is disabled - This account is currently disabled. Please have an admin or higher contact our support for more information

**Ensure all required parameters are included and the signature is generated correctly to avoid these errors.**


---

# 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://docs.swapped.com/swapped-connect/connect-integration/iframe-initialization.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.
