🔗iFrame initialization

Required Parameters

  • apiKey: Your publishable API key for customer and transaction assignment. Also known as the public key.

  • currencyCode: The cryptocurrency code (e.g., BTC, ETH, BCH) for purchase. See Supported Cryptocurrencies for more options. If multiple walletAddress are set, this will be the default cryptocurrency.

  • walletAddress: The destination cryptocurrency wallet address for purchased funds. For instance, if you want to accept Bitcoin, Litecoin, and Dogecoin, format the walletAddress parameter as follows: walletAddress=BTC:yourBitcoinAddress,LTC:yourLitecoinAddress,DOGE:yourDogecoinAddress. Note that the code is case sensitive so ensure the code you use for your default cryptocurrency matches what you used in currencyCode field.

Optional Parameters

  • language: Specify the widget's language using an ISO 639 Set 1 code. The language will default to EN (English) if the parsed language is not supported. Currently supported languages: EN, DA, TR, NL, MS, FR, JA, IT, ES, FI, ID, PL, PT, PT-BR RO, SV, VI, DE, NO and ET.

  • baseCurrencyCode: The fiat currency code for transactions (e.g., USD, EUR, GBP). See Supported Fiat currencies for more options.

  • lockBaseCurrency: (True/False) Locks the currency selection to the provided baseCurrencyCode. This prevents the user from making payments in other currencies, and will remove payment methods where the provided currency is unsupported.

  • baseCurrencyAmount: The fiat currency amount to be spent, in integer form. 2 decimals max. Cannot be zero if set.

  • quoteCurrencyAmount: The cryptocurrency amount to be purchased, in integer form. 3 decimals max. Minimum 7 EUR and 8 USD equivalent of the given crypto.

  • email: The email address of the customer.

  • externalCustomerId: Your unique identifier for the customer.

  • redirectUrl: The URL for redirection after purchase completion. Must be URLencoded, e.g. https%3A%2F%2Fwww.myurl.com.

  • customerKYC: The level of Know Your Customer (KYC) verification. customerKYC = 0 means the customer has not completed KYC. customerKYC = 1 means the customer has completed Proof of ID + Liveness Check. customerKYC = 2 means the customer has completed Proof of ID + Liveness Check + Proof of Address.

  • style: The Styling ID and widget customization options can be configured on the “Widget Customizations” page within the Swapped.com Dashboard.

  • destinationTag: Adds a destination tag / memo to the transaction. Only supported for XRP and TON.

  • coverFees: (True/False) Sets processing and handling fees to zero for the customer. Fees will be included through the spread.

  • minAmount: Sets the minimum order amount in EUR. This cannot be lower than 7 EUR.

  • lockAmount: (True/False) Locks the fiat and crypto fields for the user.

  • baseCountry: (ISO) The country code for the user's location. This is used to determine the payment methods available to the user. See supported countries for more options. Note that if lockAmount is set to true, the country will not be changeable by the user.

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

import crypto from 'crypto';

const publicKey = 'your_public_key';
const secretKey = 'your_secret_key';
const currencyCode = 'currency_code';
const walletAddress = 'your_wallet_address';

const originalUrl = `https://widget.swapped.com?apiKey=${publicKey}&currencyCode=${currencyCode}&walletAddress=${walletAddress}`;
const signature = crypto.createHmac('sha256', secretKey).update(new URL(originalUrl).search).digest('base64');
const urlWithSignature = `${originalUrl}&signature=${encodeURIComponent(signature)}`;

console.log(urlWithSignature);

Example with PHP

<?php

$publicKey = 'your_public_key';
$secretKey = 'your_secret_key';
$currencyCode = 'currency_code';
$walletAddress = 'your_wallet_address';

$originalUrl = "https://widget.swapped.com?apiKey={$publicKey}&currencyCode={$currencyCode}&walletAddress={$walletAddress}";
$parsedUrl = parse_url($originalUrl);
$signature = base64_encode(hash_hmac('sha256', '?'.$parsedUrl['query'], $secretKey, true));
$urlWithSignature = "{$originalUrl}&signature=" . urlencode($signature);

echo $urlWithSignature;

Example iFrame URL

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

https://widget.swapped.com?apiKey={pk_live_key}&currencyCode=btc&signature=loremipsum

Example iFrame

<iframe allow="accelerometer; autoplay; camera; encrypted-media; gyroscope; payment; clipboard-read; clipboard-write" src="https://widget.swapped.com?apiKey={pk_live_key}&currencyCode=btc&signature=lorem" title="Buy crypto with Swapped" style="height: 585px; width: 445px; border-radius: 
0.75rem; margin: auto;"></iframe>

Last updated