Skip to main content

Topup your Wallet in PnP Web Modal SDK

For topping up the wallet of a user, you can use the initiateTopup() function. This method takes in the parameters of the selected payment provider and accordingly gives you the option to seemless add money to your user's wallet address directly.

info

This uses the Torus EVM Wallet UI Plugin and Torus Solana Wallet UI Plugin for the respective chains. Please install and configure the packages before using this function.

initiateTopup()

Initiates the Top Up flow with selected provider.

Arguments

ParameterTypeDescriptionMandatory
providerPAYMENT_PROVIDER_TYPE ["moonpay", "wyre", "rampnetwork", "xanpool", "mercuryo", "transak", "banxa"]Payment Provider nameYes
paramsPaymentParamsPayment Params objectYes

PaymentParams

ParameterTypeDescriptionMandatory
selectedAddress?stringAddress to send the funds toNo
selectedCurrency?stringDefault fiat currency for the user to make the payment inNo
fiatValue?numberAmount to buy in the selectedCurrencyNo
selectedCryptoCurrency?stringCryptocurrency to buyNo
chainNetwork?SUPPORTED_PAYMENT_NETWORK_TYPE ["mainnet", "matic", "bsc_mainnet", "avalanche_mainnet", "xdai"]Chain Network to useNo

Example

import { TorusWalletConnectorPlugin } from "@web3auth/torus-wallet-connector-plugin";

const torusPlugin = new TorusWalletConnectorPlugin({
torusWalletOpts: {},
walletInitOptions: {
whiteLabel: {
theme: { isDark: true, colors: { primary: "#00a8ff" } },
logoDark: "https://web3auth.io/images/w3a-L-Favicon-1.svg",
logoLight: "https://web3auth.io/images/w3a-D-Favicon-1.svg",
},
useWalletConnect: true,
enableLogging: true,
},
});

await web3auth.addPlugin(torusPlugin); // add plugin to web3auth instance

await torusPlugin.initiateTopup("moonpay", {
selectedAddress: "wallet_address",
selectedCurrency: "USD", // Fiat currency
fiatValue: 100, // Fiat Value
selectedCryptoCurrency: "ETH", // Cryptocurreny `SOL`, `MATIC` etc.
chainNetwork: "mainnet", // Blockchain network
});

Initiates the Top Up flow with selected provider.

Arguments

ParameterTypeDescriptionMandatory
providerPAYMENT_PROVIDER_TYPE ["moonpay", "wyre", "rampnetwork", "xanpool", "mercuryo", "transak"]Payment Provider nameYes
paramsPaymentParamsPayment Params objectYes

PaymentParams

ParameterTypeDescriptionMandatory
selectedAddress?stringAddress to send the funds toNo
selectedCurrency?stringDefault fiat currency for the user to make the payment inNo
fiatValue?numberAmount to buy in the selectedCurrencyNo
selectedCryptoCurrency?stringCryptocurrency to buyNo
cyptoAmount?numberAmount Cryptocurrency to buyNo

Example

import { SolanaWalletConnectorPlugin } from "@web3auth/solana-wallet-connector-plugin";

const torusPlugin = new SolanaWalletConnectorPlugin({
torusWalletOpts: {},
walletInitOptions: {
whiteLabel: {
theme: { isDark: true, colors: { primary: "#00a8ff" } },
logoDark: "https://web3auth.io/images/w3a-L-Favicon-1.svg",
logoLight: "https://web3auth.io/images/w3a-D-Favicon-1.svg",
},
},
});

await web3auth.addPlugin(torusPlugin); // add plugin to web3auth instance

await torusPlugin.initiateTopup("moonpay", {
selectedAddress: "wallet_address",
selectedCurrency: "USD", // Fiat currency
fiatValue: 100, // Fiat Value
selectedCryptoCurrency: "ETH", // Cryptocurreny `SOL`, `MATIC` etc.
});

Supported Cryptocurrency

Supported Cryptocurrency for each Payment Provider by Network

MOONPAY

NetworkSupported Cryptocurrency
mainnetAAVE, BAT, DAI, ETH, MKR, MATIC, USDT , USDC
maticETH: eth_polygon, MATIC: matic_polygon, USDC: usdc_polygon
bsc_mainnetBNB: bnb_bsc, BUSD: busd_bsc
avalanche_mainnetAVAX: avax_cchain

WYRE

NetworkSupported Cryptocurrency
mainnetAAVE, BAT, BUSD, DAI, ETH, MKR, UNI , USDC, USDT
maticUSDC: MUSDC
avalanche_mainnetAVAX

RAMPNETWORK

NetworkSupported Cryptocurrency
mainnetETH, DAI, USDC, USDT
maticMATIC_DAI, MATIC_MATIC , MATIC_USDC
avalanche_mainnetAVAX

XANPOOL

NetworkSupported Cryptocurrency
mainnetETH, USDT

MERCURYO

NetworkSupported Cryptocurrency
mainnetETH, BAT, USDT, DAI
bsc_mainnetBNB, BUSD, 1INCH

TRANSAK

NetworkSupported Cryptocurrency
mainnetAAVE, DAI, ETH, USDC, USDT , CHAIN
maticAAVE, DAI, MATIC, USDC, USDT , WETH, CHAIN
bsc_mainnetBNB, BUSD
avalanche_mainnetAVAX

BANXA

NetworkSupported Cryptocurrency
mainnetETH, USDT, BUSD, LINK, USDC, CHZ, BAT, MANA, AAVE, COMP, ENJ
maticMATIC