question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi! I have this code:

<script>
  import { onMount } from "svelte";
  import Web3 from "web3";
  import Web3Modal from "web3modal";

  import WalletConnectProvider from "@walletconnect/web3-provider";

  let web3Modal;
  let provider;
  let web3;

  const connect = async () => {
    provider = await web3Modal.connect();

    provider.on("accountsChanged", accounts => {
      console.log(accounts);
    });

    provider.on("chainChanged", chainId => {
      console.log(chainId);
    });

    provider.on("connect", info => {
      console.log(info);
    });

    provider.on("disconnect", error => {
      console.log(error);
    });

    web3 = new Web3(provider);
    console.log(await web3.eth.getGasPrice())
    web3.eth.getAccounts(console.log);
  }

  onMount(async () => {
    const providerOptions = {
      disableInjectedProvider: true,
      // cacheProvider: false,
      walletconnect: {
        package: WalletConnectProvider,
        options: {
          infuraId: "<THE INFURA PROJECT ID>",
        }
      },
      binancechainwallet: {
        package: true
      }
    };

    web3Modal = new Web3Modal(providerOptions)
  })
</script>

<button class={ $$props.class } on:click={ connect }><slot>Connect</slot></button>
{ web3 }

When the button is clicked, the opacity of the screen changes but the modal doesn’t show Looking at the html you can see this:

<div id="WEB3_CONNECT_MODAL_ID">
  <div class="sc-jRQBWg uYscM web3modal-modal-lightbox" offset="0" opacity="0.4">
    <div class="sc-gKclnd fmSSut web3modal-modal-container">
      <div class="sc-iCfMLu fFpYRP web3modal-modal-hitbox"></div>
      <div class="sc-furwcr dKfWpB web3modal-modal-card"></div>
    </div>
  </div>
</div>

Sorry if this is a newbie issue but I don’t catch what is happening

Thanks

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

2reactions
YannSuissacommented, Apr 11, 2022

I have the same issue when metamask is installed but not enabled, just an empty darker div

1reaction
YannSuissacommented, May 25, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to reset the bootstrap modal when it gets closed and ...
I am using BS 3.3.7 and i have a problem when i open a modal then close it, the modal contents keep on...
Read more >
Modal - Bootstrap
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >
Clear Modal Form On Close - Material Design for Bootstrap
Hello, I have a modal form based on the examples, when a user partially completes the form but presses cancel to close the...
Read more >
Clear Bootstrap Modal content after close. - Coderwall
This tells Bootstrap to clear everything on the close of the modal window, so you won't get cached content. Of course you need...
Read more >
Create empty modal dialog box - MATLAB dialog - MathWorks
This MATLAB function creates an empty dialog box and returns d, a Figure object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found