current position:Home>Use ethers JS failed to generate Wallet

Use ethers JS failed to generate Wallet

2022-02-03 20:54:17 Q & A of Denglian community

error message

TypeError: Cannot read property 'sendTransaction' of undefined

The reason for the error is that the wallet... Was not generated , But I seem to have generated a wallet . My backstage is koa. When I start the background, I directly use the private key to generate a wallet SUEXTK9EOYNGPC0U3GFYT.png

I put contract、provider、manager After export , At the project entrance file index.js Put into global variables UZ04HRR259OO.png

Then I'm using manager That's when the wallet , It happened. underfined error . I printed these three variables before the error , Find out contract and provider It's normal , however manager It becomes underfined. I don't understand what went wrong .1FQL3JOS5A3DATEPTOBQM.png

All other interactions with Ethereum are OK . For example, use an account with balance to write something into the smart contract .

Take the answer 1:

Probably yours provider Not connected .

You still need to debug yourself .

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.

Random recommended