web3 unlock account error

by Ntydrm   Last Updated June 12, 2019 07:28 AM

I have two geth nodes, each has an account:

node1(IP:192.168.43.12): account1
node2(IP:192.168.43.39): account2

the two accounts are created using geth --datadir /root/chain/node1/data account new, the keystore files are generated and saved on each node.

I use web3 to attach node1 in nodejs environment:

const Web3 = require('web3');
const web3 = new Web3('http://192.168.43.12:8545');

and try to unlock account2 created on node2 before sending a token transaction like below:

await web3.eth.personal.unlockAccount(account2, "account2 password", 1000);

I got an error like below:

Error: Node error: {"code":-32000,"message":"no key for given address or file"}

I also tried if attach to node2 and the unlock process is correct.

const Web3 = require('web3');
const web3 = new Web3('http://192.168.43.39:8545');
await web3.eth.personal.unlockAccount(account2, "account2 password", 1000);

How can I unlock an account use web3 without the limitation of node connection?

Thanks.

Tags : go-ethereum


Answers 1


The account files are located in /root/chain/node1/data/keystore folder (in your case), so you need to copy both keys to both nodes, because the accounts are local per node

KNK
KNK
June 12, 2019 07:27 AM

Related Questions



External functions calling other functions

Updated July 11, 2018 03:28 AM


Forced data location

Updated July 09, 2018 23:28 PM