web-examples icon indicating copy to clipboard operation
web-examples copied to clipboard

can i use walletconnect on browser(pure javascript)

Open arlong87 opened this issue 1 year ago • 3 comments

hello. can i use on browser? Are there any examples? I tried to import the packages but I failed.


<script type="module">
  import { Core } from 'https://unpkg.com/@walletconnect/core'
</script>

<script type="module">
  import { Web3Wallet } from 'https://unpkg.com/@walletconnect/web3wallet'
</script>

<script type="text/javascript">
const core = new Core({
  projectId: 'ggggggggggggggggggggggg'
})

const metadata = {
  name: 'gggggg-3',
  description: 'AppKit Example',
  url: 'https://web3modal.com', // origin must match your domain & subdomain
  icons: ['https://avatars.githubusercontent.com/u/37784886']
}

const web3wallet = await Web3Wallet.init({
  core, // <- pass the shared 'core' instance
  metadata
})

</script>

error on console:

Uncaught SyntaxError: The requested module 'https://unpkg.com/@walletconnect/core' does not provide an export named 'Core' (at test.html:2:12)
Uncaught SyntaxError: The requested module 'https://unpkg.com/@walletconnect/web3wallet' does not provide an export named 'Web3Wallet' (at test.html:6:12)

arlong87 avatar Aug 07 '24 19:08 arlong87

We don't officially support CDN ATM

glitch-txs avatar Aug 07 '24 22:08 glitch-txs

too bad.

arlong87 avatar Aug 08 '24 05:08 arlong87

You can use Vite which supports HTML projects

glitch-txs avatar Aug 08 '24 11:08 glitch-txs