1

This question already has an answer here:

I am at Geth/v1.9.0-stable-52f24617/linux-amd64/go1.11.5

web3JS version is giving :

> web3.version
{
  api: "0.20.1",
  ethereum: "0x2712",
  network: "4",
  node: "Geth/v1.9.0-stable-52f24617/linux-amd64/go1.11.5",
  whisper: undefined,
  getEthereum: function(callback),
  getNetwork: function(callback),
  getNode: function(callback),
  getWhisper: function(callback)
}

I have an account address, private key and passphrase and now want to import it into in my geth account. One way I got is using

**web3.eth.accounts.wallet.add()**

but, this is not working with the current version I have, it is giving me undefined

marked as duplicate by Ismael, Richard Horrocks, alberto, shane, Achala Dissanayake Sep 9 at 14:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

It seems you are using a function from Web3.js 1.x:
https://web3js.readthedocs.io/en/v1.2.1/web3-eth-accounts.html#wallet-add

However the console from Geth uses web3.js 0.20.1, which is documented here:
https://github.com/ethereum/wiki/wiki/JavaScript-API

You could use the Geth function: personal.importRawKey(keydata, passphrase):
https://geth.ethereum.org/interface/Management-APIs#personal_importrawkey

Alternatively you could use web3.js 1.x from for example node.js
Install web3:

npm install web3

Start geth with RPC interface

geth --rpc 

And the create a test.js:

const Web3 = require('web3');
const web3 = new Web3('http://localhost:8545' );
console.log(web3.version);
...web3.eth.accounts.wallet.add(...)

Not the answer you're looking for? Browse other questions tagged or ask your own question.