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.

Uncaught (in promise) TypeError: Cannot read property 'generateKey' of undefined

See original GitHub issue

Hello,

I am new in this WalletConnect I am creating client sdk on browser side but getting some issue while performing createSession method. Can you please help me out with that.

Code of Walletconnect Initial Connection :

const walletConnector = new WalletConnect({
  bridge: "https://bridge.walletconnect.org" // Required
});

/**
  *  Check if connection is already established
  */
if (!walletConnector.connected) {
  // create new session
    walletConnector.createSession().then(() => {
    console.log("session");
    const uri = walletConnector.uri;
    console.log("uri" + uri);
    console.log("wallet" + walletConnector.connected);
    // display QR Code modal
    WalletConnectQRCodeModal.open(uri, () => {
      console.log("QR Code Modal closed");
    });
  });
  // walletConnector.updateSession({chainId : 0,accounts :walletConnector.accounts});
  // get uri for QR Code modal
}
/**
  *  Subscribe to connection events
  */
walletConnector.on("connect", (error, payload) => {
  console.log("connect");
  if (error) {
    throw error;
  }

  // close QR Code Modal
  WalletConnectQRCodeModal.close();

  // // get provided accounts and chainId
  // const { accounts, chainId } = payload.params[0];
});

walletConnector.on("session_update", (error, payload) => {
  console.log("session_update");
  if (error) {
    throw error;
  }

  // get updated accounts and chainId
  const { accounts, chainId } = payload.params[0];
});

walletConnector.on("disconnect", (error, payload) => {
  console.log("disconnect");
  if (error) {
    throw error;
  }

  // delete walletConnector
});

Issue while running on browser :

screenshot 2019-02-27 at 3 57 48 pm

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
koirikivicommented, May 24, 2019

I got a similar issue and found this by googling, so maybe this will help someone. In my case, the issue was that I was trying to access the page with Chrome on an insecure local network url (http://192.168.1.xxx), but Chrome doesn’t expose window.crypto.subtle in insecure contexts. Firefox seems to work, and I’d guess http://localhost… would also work.

1reaction
pedrouidcommented, Feb 27, 2019

Thanks @astha-nimblechapps! 🙌 Someone else also reported this and I was about to publish beta.5 so I will just take a quick look and include the fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'generateKey' of undefined · Issue #964 ...
Uncaught TypeError : Cannot read property 'generateKey' of undefined. It seems like it's coming from the webcrypto package.
Read more >
Cannot read property 'importKey' of undefined, Web Crypto ...
I tried and got the solution. You can simply use the private key. Here it is: var sha256 = forge.md.sha256.create(); sha256.update(message, ...
Read more >
SubtleCrypto.generateKey() - Web APIs | MDN
A Promise that fulfills with a CryptoKey (for symmetric algorithms) or a CryptoKeyPair (for public-key algorithms). Exceptions. The promise is ...
Read more >
uncaught typeerror: cannot read properties of undefined (reading ...
Getting error Uncaught TypeError: Cannot read properties of undefined (reading 'generateKey') only when I run the flutter app over any server (apache2 in...
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
As a JavaScript developer, I'm sure you've encountered the frustrating runtime TypeError Cannot read properties of undefined .
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