WDK logoWDK documentation
TransakGuides

Buy and Sell

On-ramp, off-ramp, quotes, supported assets, widget options, and custom recipients.

This guide explains buying crypto (on-ramp), selling crypto (off-ramp), quotes, supported currencies, widget customization, multi-network assets, and custom recipients. It assumes a server-side TransakProtocol instance named transak, constructed with the recommended undefined account.

Run every transak.* call in this guide on your backend, then return only the result your authenticated client needs. For buy() and sell(), open the returned widget URL in the user's browser. Do not construct TransakProtocol in browser code.

Amounts use base units: fiat in minor units (cents), crypto in on-chain base units (for example wei for ETH). cryptoAsset/fiatCurrency are upper-case (ETH, EUR), while network/paymentMethod are lower-case (ethereum, credit_debit_card). Codes are matched exactly, with no normalisation, so fetch the exact values with supported currencies.

Buy crypto (on-ramp)

You can build a buy widget URL with buy() when you know the fiat spend:

Buy with fiat amount
const result = await transak.buy({
  cryptoAsset: 'ETH',
  fiatCurrency: 'EUR',
  fiatAmount: 10_000n, // €100.00 in cents
  config: { referrerDomain: 'yourdomain.com' }
})

You can request a fixed crypto amount instead by passing cryptoAmount to buy():

Buy with crypto amount
const result = await transak.buy({
  cryptoAsset: 'ETH',
  fiatCurrency: 'EUR',
  cryptoAmount: 500000000000000000n, // 0.5 ETH in wei
  config: { referrerDomain: 'yourdomain.com' }
})

referrerDomain is required for buy/sell. Transak's Create Widget URL API rejects requests without config.referrerDomain (your web domain or app package name). It may need allow-listing in the Partner dashboard first. quoteBuy/quoteSell don't need it.

Sell crypto (off-ramp)

You can generate a sell widget URL with sell():

Sell ETH for EUR
const result = await transak.sell({
  cryptoAsset: 'ETH',
  fiatCurrency: 'EUR',
  cryptoAmount: 500000000000000000n, // 0.5 ETH in wei
  config: { referrerDomain: 'yourdomain.com' }
})

Get price quotes

You can preview economics before opening the widget using quoteBuy():

Buy quote
const buyQuote = await transak.quoteBuy({
  cryptoAsset: 'ETH',
  fiatCurrency: 'EUR',
  fiatAmount: 10_000n // €100.00 in cents
})

console.log('Crypto amount:', buyQuote.cryptoAmount)
console.log('Fee:', buyQuote.fee)
console.log('Exchange rate:', buyQuote.rate)

You can estimate proceeds for a sell with quoteSell(). Note that cryptoAmount is required, since unlike quoteBuy, quoteSell doesn't accept a fiatAmount:

Sell quote
const sellQuote = await transak.quoteSell({
  cryptoAsset: 'ETH',
  fiatCurrency: 'EUR',
  cryptoAmount: 500000000000000000n // 0.5 ETH in wei
})

console.log('Fiat amount:', sellQuote.fiatAmount)

Supported currencies and countries

You can list tradable assets with getSupportedCryptoAssets()

Supported crypto
const cryptoAssets = await transak.getSupportedCryptoAssets()
console.log(cryptoAssets)

You can list fiat currencies with getSupportedFiatCurrencies()

Supported fiat
const fiatCurrencies = await transak.getSupportedFiatCurrencies()
console.log(fiatCurrencies)

You can check regional availability with getSupportedCountries():

Supported countries
const countries = await transak.getSupportedCountries()
console.log(countries)

Both directional flags mirror Transak's country-level KYC availability signal. They do not guarantee that a particular asset, fiat currency, network, or payment method is available, so check the corresponding supported lists and let the widget perform its final eligibility checks.

Widget customization

You can pass UI options under config to buy() (see TransakBuyParams):

Themed buy widget
const result = await transak.buy({
  cryptoAsset: 'ETH',
  fiatCurrency: 'EUR',
  fiatAmount: 5_000n,
  config: {
    network: 'ethereum',
    paymentMethod: 'credit_debit_card',
    referrerDomain: 'yourdomain.com',
    colorMode: 'DARK',
    redirectURL: 'https://yourapp.com/payment-complete',
    email: 'user@example.com',
    partnerCustomerId: 'user_123'
  }
})

Multi-network assets

A symbol such as USD₮ can exist on several networks. Retrieve the provider's exact code and pass config.network to disambiguate. Otherwise, the module resolves the first match:

Sell USDt on Tron specifically
const USDtAssetCode = 'USDt'
const USDtOnTron = (await transak.getSupportedCryptoAssets()).find(
  ({ code, networkCode }) => (
    code.toLowerCase() === USDtAssetCode.toLowerCase() && networkCode === 'tron'
  )
)

if (!USDtOnTron) throw new Error('USDt is not available on Tron')

const result = await transak.sell({
  cryptoAsset: USDtOnTron.code,
  fiatCurrency: 'EUR',
  cryptoAmount: 100_000_000n, // 100 USDt, 6 decimals
  config: { network: 'tron', referrerDomain: 'yourdomain.com' }
})

If the requested cryptoAsset/fiatCurrency/network combination can't be found in the supported lists, buy, sell, quoteBuy, and quoteSell all throw Cannot find info for cryptoAsset and fiatCurrency.

Custom recipient addresses

Pass a validated destination address to buy() with recipient when you want to prefill the widget:

Custom buy recipient
const result = await transak.buy({
  cryptoAsset: 'ETH',
  fiatCurrency: 'EUR',
  fiatAmount: 10_000n,
  recipient: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
  config: { referrerDomain: 'yourdomain.com' }
})

If recipient isn't provided, the module falls back to a bound read-only account's address. With the recommended undefined account, the Transak widget prompts the user for one. Validate any client-supplied address for the selected network before passing it to your backend protocol instance.

Next Steps

On this page