0

** this is my previous post : web3.eth.accounts.wallet.add(account) not working

what I have tried?

-1:

web3 = new Web3(new Web3.providers.HttpProvider(connectionString));
const account = await web3.eth.accounts.privateKeyToAccount('0x'+pvKey);
await web3.eth.accounts.wallet.add(account);
console.log(await web3.eth.getAccounts()); // return []..

-2:

web3.personal.importRawKey("<Private Key>","<New Password>")

how I can add a new wallet to the web3 object, to run contract functions?

  • What web3 provider are you using? ie infura, own node, .. – Ismael Feb 26 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.