Closed mishell-trickster closed 5 years ago
I did not know that the key must start with 0x.
Just post for people might meet the same situation like me...
for web3.eth.accounts.wallet.add(account)
the private key must start with 0x too.
I am using geth 1.9.0 which has web3 version api: "0.20.1",
How can I import account here using key and address?
web3.eth.accounts.wallet.add
is returning undefined
I start ganache-gui and see lot of accounts, they has privat keys and mnemonic phrase. Then I connect to this testnet with nodejs and web3 1.x.x, so my wallet.length is 0. I want to import all wallet from ganache by mnemonic phrase or better import one address using private key. Could I do this? I tried
web3.eth.accounts.privateKeyToAccount(privateKey);
but its return new account. How it works? Metamask can do this by privateKey.