API Reference
API Reference for the @tetherto/wdk-protocol-fiat-moonpay module
Complete API documentation for the @tetherto/wdk-protocol-fiat-moonpay module.
new MoonPayProtocol(account, config)
Creates a new MoonPayProtocol instance.
Parameters:
IWalletAccount | IWalletAccountReadOnly | undefined
Wallet account for transactions
Config Options:
Name
Type
Required
Default
Description
Your MoonPay publishable API key
Cache duration for currencies (ms)
Example:
import MoonPayProtocol from '@tetherto/wdk-protocol-fiat-moonpay';
const moonpay = new MoonPayProtocol(walletAccount, {
apiKey: 'pk_live_xxxxx',
secretKey: 'sk_live_xxxxx',
});
Generates a signed widget URL for purchasing cryptocurrency.
Parameters:
Name
Type
Required
Description
Cryptocurrency code (e.g., 'eth', 'btc')
Fiat currency code (e.g., 'usd', 'eur')
Amount in smallest crypto units
Amount in smallest fiat units (cents)
Wallet address (uses account address if not provided)
Widget configuration options
*Either cryptoAmount or fiatAmount must be provided, but not both.
Returns: Promise<{ buyUrl: string }>
Generates a signed widget URL for selling cryptocurrency.
Parameters:
Name
Type
Required
Description
Amount in smallest crypto units
Amount in smallest fiat units
Widget configuration options
Returns: Promise<{ sellUrl: string }>
quoteBuy(options)
Gets a price quote for a cryptocurrency purchase.
Parameters:
Name
Type
Required
Description
Amount in smallest crypto units
Amount in smallest fiat units
Returns: Promise<MoonPayBuyQuote>
quoteSell(options)
Gets a price quote for selling cryptocurrency.
Parameters:
Name
Type
Required
Description
Amount in smallest crypto units
Returns: Promise<MoonPaySellQuote>
getSupportedCryptoAssets()
Fetches the list of supported cryptocurrencies. Results are cached.
Returns: Promise<MoonPaySupportedCryptoAsset[]>
getSupportedFiatCurrencies()
Fetches the list of supported fiat currencies. Results are cached.
Returns: Promise<MoonPaySupportedFiatCurrency[]>
getSupportedCountries()
Fetches the list of supported countries.
Returns: Promise<MoonPaySupportedCountry[]>
getTransactionDetail(txId, direction?)
Retrieves details of a specific transaction.
Parameters:
Name
Type
Required
Default
Description
Returns: Promise<MoonPayTransactionDetail>
MoonPayProtocolConfig
MoonPayBuyParams / MoonPaySellParams
Widget configuration options:
MoonPayQuoteBuyParams
MoonPayQuoteSellParams