How to use wallet connect v3 in JavaScript module

344 Views Asked by At

I've installed required packages using below command:

npm install @web3modal/wagmi @wagmi/core viem

And tried to use this code in my script.js (frontend code):

import { createWeb3Modal, defaultWagmiConfig } from '@web3modal/wagmi'
import { mainnet, arbitrum } from '@wagmi/core/chains'

const projectId = 'xxxxxxxxx'
const metadata = {
    name: 'Web3Modal',
    description: 'Web3Modal Example',
    url: 'https://web3modal.com',
    icons: ['https://avatars.githubusercontent.com/u/37784886']
}

const chains = [mainnet, arbitrum]
const wagmiConfig = defaultWagmiConfig({ chains, projectId, metadata })

const modal = createWeb3Modal({ wagmiConfig, projectId, chains })

But I face this error:

Uncaught TypeError: Failed to resolve module specifier "@web3modal/wagmi". Relative references must start with either "/", "./", or "../".

How to add web3 wallet-connect v3 to my frontend script?

0

There are 0 best solutions below