1

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

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(...)

Your Answer

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

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