How to use @walletconnect/web3-provider - 2 common examples

To help you get started, we’ve selected a few @walletconnect/web3-provider examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github loomnetwork / dashboard / src / store / ethereum / wallets / walletconnect.ts View on Github external
async createProvider(config: EthereumConfig) {

    const net = config.networkId === "1" ? "mainnet" : "rinkeby"

    const provider = new WalletConnectProvider({
      bridge: "https://bridge.walletconnect.org",
      // infuraId: "5Ic91y0T9nLh6qUg33K0", // Required
      infuraId: "44ad2034a545495ca22dda2a4d50feba",
    })
    provider.on("chainChanged", (chainId) => console.log("chainChanged", chainId))
    provider.on("networkChanged", (net) => console.log("networkChanged", net))
    provider.on("accountsChanged", (acc) => window.location.reload())
    // wc is WalletConnect class in library
    provider.wc.on('disconnect', (error, payload) => {
      if (error) {
        throw error
      }
      console.log("User cancel a sign-in request")
      WalletConnectQRCodeModal.close()
      provider.updateState({...INITIAL_STATE})
    })
github web3connect / web3connect / src / core / connectors / walletconnect.ts View on Github external
return new Promise(async (resolve, reject) => {
    let bridge = "https://bridge.walletconnect.org";
    let qrcode = true;
    let onUri: SimpleFunction | null = null;

    if (opts) {
      bridge = opts.bridge || bridge;
      qrcode = typeof opts.qrcode !== "undefined" ? opts.qrcode : qrcode;
      onUri = opts.onUri || onUri;
    }

    if (!qrcode && !onUri) {
      throw new Error("Must provide onUri callback when qrcode is disabled");
    }

    const provider = new WalletConnectProvider({ bridge, qrcode });

    if (!provider.wc.connected) {
      await provider.wc.createSession();

      if (onUri) {
        onUri(provider.wc.uri);
      }

      provider.wc.on("connect", async (error: Error) => {
        if (error) {
          return reject(error);
        }

        return resolve(provider);
      });
    } else {

@walletconnect/web3-provider

Web3 Provider for WalletConnect

Apache-2.0
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular @walletconnect/web3-provider functions