Skip to main content

Topup

Top-up your cryptocurrency through our fiat-to-crypto partners with ease.


initiateTopup​

Use the initiateTopup function to start a top-up transaction with the selected provider from the dapp. Check the list below for supported values of parameters and providers.

const paymentStatus = await torus.initiateTopup(provider, params);

Parameters

NameTypeDescriptionMandatory
providerPAYMENT_PROVIDER_TYPEThe specified payment provider partner.Yes
paramsPaymentParamsThe topup tx params. used to autofill the form for that specific providerYes

Returns

  • Promise<boolean> : Returns a promise which resolves to a boolean indicating whether the user has successfully completed the top-up flow.

PAYMENT_PROVIDER_TYPE​

The list of PAYMENT_PROVIDER_TYPE:

  • topper

PaymentParams​

Parameters

NameTypeDescriptionMandatory
selectedAddressstringAddress to send the funds toNo
selectedCurrencystringDefault fiat currency for the user to make the payment inNo
selectedCryptoCurrencystring'XRP' to buyNo
cryptoAmountnumberAmount Cryptocurrency to buyNo

Reference​

export interface PaymentParams {
/**
* Address to send the funds to
*/
selectedAddress?: string;
/**
* Default fiat currency for the user to make the payment in
*/
selectedCurrency?: string;
// /**
// * Amount to buy in the selectedCurrency
// */
// fiatValue?: number;
/**
* Cryptocurrency to buy
*/
selectedCryptoCurrency?: string;
/**
* Amount Cryptocurrency to buy
*/
cryptoAmount?: number;
}

Example​

// Default using wallet selected address
const result = await torus?.initiateTopup("topper" as any, {
selectedCurrency: "USD",
cryptoAmount: 100,
selectedCryptoCurrency: "XRP",
});

The above example will initiate a top-up transaction with the topper provider and autofill the form with the wallet-selected address.