Connect metamask to Fiat on ramp aggregator

i am using the “@web3auth/no-modal”: “^9.1.0” SDK
in a Web environment in Vue

My dApp already has a wallet connection to metamask and other providers through the browser extensions. I’ve already implemented the no-modal connection to web3auth, i am implementing now the Wallet Services, and i want to know if i can connect a metamask wallet to the fiat on ramp feature still using the no-modal SDK

here is my web3auth connector:

import { Web3AuthNoModal } from '@web3auth/no-modal'
import { CHAIN_NAMESPACES, type IProvider, WALLET_ADAPTERS, WEB3AUTH_NETWORK } from '@web3auth/base'
import { WalletConnector, type ChainId, numberToHex, ChainIds, chainRegistry, EthErrors } from '@ryze-blockchain/ethereum'
import { AuthAdapter } from '@web3auth/auth-adapter'
import { EthereumPrivateKeyProvider } from '@web3auth/ethereum-provider'
import { WalletServicesPlugin } from '@web3auth/wallet-services-plugin'
import { type NuxtEnv } from '~/nuxt.types'

const initialChainId = ChainIds.ARBITRUM
const initialChain = chainRegistry[initialChainId]

const chainConfig = {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: numberToHex(initialChain.id),
    rpcTarget: initialChain.rpcList[0],
    displayName: initialChain.name,
    blockExplorerUrl: initialChain.explorer,
    ticker: initialChain.currency.symbol,
    tickerName: initialChain.name,
    logo: `/images/chains/${ initialChain.name.toLowerCase() }.svg`,
}

export class Web3AuthConnector extends WalletConnector<IProvider> {
    public readonly id: string = 'web3auth'
    public readonly name: string = 'Login with Google'
    private static initialized = false
    private static web3auth: Web3AuthNoModal | null = null
    private static walletServicesPlugin: WalletServicesPlugin | null = null

    private async initializeWeb3Auth(): Promise<void> {
        if (Web3AuthConnector.initialized) return

        const config = useRuntimeConfig()
        const { web3AuthClientId } = config.public as unknown as NuxtEnv['public']

        const privateKeyProvider = new EthereumPrivateKeyProvider({
            config: { chainConfig },
        })

        Web3AuthConnector.web3auth = new Web3AuthNoModal({
            clientId: web3AuthClientId,
            web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
            privateKeyProvider,
            uiConfig: {
                appName: 'DefiHub',
                appUrl: 'https://defihub.fi',
                logoLight: 'https://web3auth.io/images/web3authlog.png',
                logoDark: 'https://web3auth.io/images/web3authlogodark.png',
                defaultLanguage: 'en',
                mode: 'dark',
                theme: {
                    primary: '#AAAAAA',
                },
                useLogoLoader: true,
            },
        })

        const authAdapter = new AuthAdapter()

        Web3AuthConnector.web3auth.configureAdapter(authAdapter)

        Web3AuthConnector.walletServicesPlugin = new WalletServicesPlugin({
            wsEmbedOpts: {},
            walletInitOptions: { whiteLabel: { showWidgetButton: true } },
        })
        Web3AuthConnector.web3auth.addPlugin(Web3AuthConnector.walletServicesPlugin)

        try {
            await Web3AuthConnector.web3auth.init()
            Web3AuthConnector.initialized = true
        }
        catch (initError) {
            throw new Error(`Fail to initialize web3auth: ${ (initError as Error).message }`)
        }
    }

    public async getProvider(): Promise<IProvider> {
        await this.initializeWeb3Auth()

        const web3auth = Web3AuthConnector.web3auth!

        if (!web3auth.connected) {
            try {
                await web3auth.connectTo(WALLET_ADAPTERS.AUTH, { loginProvider: 'google' })
            }
            catch (connectError) {
                throw new Error(`Failed to connect with Google login: ${ (connectError as Error).message }`)
            }
        }

        const web3authProvider = web3auth.provider

        if (!web3authProvider)
            throw new Error(EthErrors.PROVIDER_UNAVAILABLE)

        return web3authProvider
    }

    public async addChain(chainId: ChainId): Promise<void> {
        const chain = chainRegistry[chainId]

        if (!chain)
            throw new Error(`Chain ID ${ chainId } not supported`)

        const isTestnet = chainId === ChainIds.BNB_TESTNET || chainId === ChainIds.ARBITRUM_TESTNET

        const chainData = {
            chainId: numberToHex(chain.id),
            displayName: chain.name,
            chainNamespace: CHAIN_NAMESPACES.EIP155,
            tickerName: chain.name,
            ticker: chain.currency.symbol,
            decimals: 18,
            rpcTarget: chain.rpcList[0],
            blockExplorerUrl: chain.explorer,
            logo: `/images/chains/${ chain.name.toLowerCase() }.svg`,
            isTestnet,
        }

        await Web3AuthConnector.web3auth!.addChain(chainData)
    }

    public async disconnect(): Promise<void> {
        await Web3AuthConnector.web3auth?.logout()
    }

    public async setChain(chain: ChainId): Promise<void> {
        await this.addChain(chain)

        await Web3AuthConnector.web3auth?.switchChain({ chainId: numberToHex(chain) })
        // The web3auth provider does not emit the chainChanged event, so we have to do it manually
        Web3AuthConnector.web3auth?.provider?.emit('chainChanged', numberToHex(chain))
    }

    public async showWalletUI(): Promise<void> {
        await Web3AuthConnector.walletServicesPlugin?.showWalletUi()
    }

    public async showWalletConnectScanner(): Promise<void> {
        await Web3AuthConnector.walletServicesPlugin?.showWalletConnectScanner()
    }

    public async showCheckout(): Promise<void> {
        await Web3AuthConnector.walletServicesPlugin?.showCheckout()
    }
}

Hi Matheus! Thank you for reaching out with your question.

From your message, I see that you’re using the @web3auth/no-modal SDK version ^9.1.0 in a Web environment with Vue. You’re looking to connect a MetaMask wallet to the fiat on-ramp feature while still utilizing the no-modal SDK.

Here’s a summary of the details for our support team:

  • SDK Details: Help - Plug n Play
  • SDK Version: ^9.1.0
  • Platform: Web (Vue)
  • Issue: Connecting MetaMask to fiat on-ramp while using no-modal SDK.

Proposed Next Steps:

You can generally connect MetaMask to your dApp’s existing wallet connection through the Wallet Services Plugin you’re using. If you want to implement it with the fiat on-ramp feature, ensure that the Wallet Services Plugin is correctly handling the connection process.

It would be useful to check any documentation regarding integrating MetaMask with fiat on-ramps to see if there’s any specific requirement or limitation.

If you’re facing a specific error or need further assistance, please let us know, and including browser console screenshots can also help greatly!

Feel free to reach out if you have more questions. Happy coding! :blush:

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Hey @matheussimasalves

The Wallet Services Functionality of Web3Auth, including the Wallet UI, Wallet Connect functions and Fiat On Ramps only work with Social Logins.

so whats the function of this parameter:

receiveWalletAddress? Specifies the recipient’s address. By default, it is set to the currently connected address.

in this doc Usage - Wallet Services Plugin | Documentation | Web3Auth

Hey, even tho there is the parameter it checks the session, which is only present for the social wallets. You can use the below url to trigger the fiat on ramp modal

https://checkout.web3auth.io/?apiKey=c7e7af2c-27c8-49c7-bc04-7e07d92a1ac2&userId=user_name&receiveWalletAddress=0xB24bf55E405cbA3199ea510B71B11E2C4acc815F

You can also config the modal using these parameters

    buildEnv?: BUILD_ENV_TYPE;
    receiveWalletAddress: string;
    apiKey: string;
    userId?: string;
    userEmail?: string;
    crypto?: string;
    fiat?: string;
    fiatAmount?: string;
    cryptoAmount?: string;
    strictMode?: boolean;
    chainId?: string;
    primaryColorHex?: string;
    textColorHex?: string;
    isDark?: boolean;