Widget Configuration

This page provides detailed information about configuring the TwoCoin widget using URL parameters. You can customize various aspects of the widget to match your needs and user experience requirements.

URL Parameters

The widget is configured using URL parameters. These parameters allow you to pre-configure various aspects of the widget:

ParameterTypeDescriptionExample
walletAddressStringPre-configured wallet address (read-only in UI)0x1234567890abcdef
hideWalletBooleanHide wallet address section (requires walletAddress)true
countryStringPre-configured country code (read-only in UI)US
stateStringPre-configured state code (requires country)NY
hideCountryAndStateBooleanHide country/state section (requires country)true
fromCurrencyStringPre-configure the source currencyUSD
toCurrencyStringPre-configure the target currencyBTC
lockCurrenciesBooleanLock currency selection to prevent changestrue
hideOrdersBooleanHide the "View Orders" buttontrue

Configuration Examples

Here are examples of how to configure the widget using URL parameters:

Basic Configuration

<!-- Basic iframe integration -->
<iframe 
  src="https://your-widget-domain.com/widget?fromCurrency=EUR&toCurrency=ETH"
  width="100%" 
  height="800px"
  frameBorder="0">
</iframe>

Advanced Configuration

<!-- Advanced configuration with multiple parameters -->
<iframe 
  src="https://your-widget-domain.com/widget?walletAddress=0x1234&hideWallet=true&country=US&state=NY&fromCurrency=USD&toCurrency=BTC&lockCurrencies=true&hideOrders=true"
  width="100%" 
  height="800px"
  frameBorder="0">
</iframe>

Programmatic URL Building

<script>
function buildWidgetUrl(baseUrl, options) {
  const params = new URLSearchParams();
  
  if (options.walletAddress) params.append('walletAddress', options.walletAddress);
  if (options.hideWallet) params.append('hideWallet', 'true');
  if (options.country) params.append('country', options.country);
  if (options.state) params.append('state', options.state);
  if (options.fromCurrency) params.append('fromCurrency', options.fromCurrency);
  if (options.toCurrency) params.append('toCurrency', options.toCurrency);
  if (options.lockCurrencies) params.append('lockCurrencies', 'true');
  if (options.hideOrders) params.append('hideOrders', 'true');
  
  return baseUrl + '?' + params.toString();
}

// Usage example
const widgetUrl = buildWidgetUrl('https://your-widget-domain.com/widget', {
  walletAddress: '0x1234567890abcdef',
  country: 'US',
  fromCurrency: 'USD',
  toCurrency: 'BTC',
  lockCurrencies: true
});

document.getElementById('widget-iframe').src = widgetUrl;
</script>

Parameter Combinations

Certain parameters work together to provide specific functionality. Here are some common combinations:

Pre-configured Trading Pair

?fromCurrency=USD&toCurrency=BTC&lockCurrencies=true

This configuration:
- Sets USD as the source currency
- Sets BTC as the target currency  
- Prevents users from changing the currencies

Location-specific Widget

?country=US&state=NY&hideCountryAndState=true

This configuration:
- Pre-configures the location to New York, US
- Hides the country/state selection from users

Wallet Pre-configuration

?walletAddress=0x1234567890abcdef&hideWallet=true

This configuration:
- Pre-fills the wallet address
- Completely hides the wallet input from users

Streamlined Experience

?walletAddress=0x1234&hideWallet=true&country=US&hideCountryAndState=true&fromCurrency=USD&toCurrency=BTC&lockCurrencies=true&hideOrders=true

This configuration provides the most streamlined experience:
- Pre-configures wallet, location, and currencies
- Hides all configuration options from users
- Focuses user attention on amount and payment selection

Next Steps

Support

If you encounter any issues or have questions not addressed in this documentation, please contact our support team on Telegram at https://t.me/cs_2coin (@cs_2coin).