0

I have these two lines of code to unlock the default account, But i keep on getting error , tough the require path points to proper directory of web3-eth-personal,

var personal = require('./node_modules/web3-eth-personal/');
personal.unlockAccount(web3.eth.defaultAccount)

The Error:

web3.min.js:1 Uncaught Error: Cannot find module './node_modules/web3-eth-personal/' at o (web3.min.js:1) at o (web3.min.js:1) at Index2.html:49

The thing is that iam able to call a function which reads value from contract, but trying to set value in contract is problem. my contract is on Ropsten test network.

Please guide.

1 Answer 1

0

Try for this:

npm install web3-eth-account --save

npm install web3-eth-personal --save

npm install web3 --save

var Accounts = require('web3-eth-accounts');
var Personal = require('web3-eth-personal');
var Web3 = require('web3');

var accounts = new Accounts(Constant.ETHnodeURL.connectETHnodeWS);
var personal = new Personal(Constant.ETHnodeURL.connectETHnodeWS);
var web3 = new Web3(new Web3.providers.WebsocketProvider(Constant.ETHnodeURL.connectETHnodeWS));

web3.eth.personal.newAccount('privatepassword').then((data) => {
   console.log('Address:'+data);
});
6
  • this line npm install web3-eth-account --save shows this error npm ERR! code E404 npm ERR! 404 Not Found: web3-eth-account@latest Commented Feb 6, 2018 at 7:37
  • check your node version, It should be graeter than 9> Commented Feb 6, 2018 at 7:42
  • I am having a simple contract Employee where there are two functions, setEmployee and GetEmployee, i am not able to call setEmployee, i am using a simple webform to update the employee, details, do you have any sample application which does something like this? Commented Feb 6, 2018 at 7:50
  • its 8.9.4, do not want to install the other version as of now..thanks for help, i Commented Feb 6, 2018 at 7:53
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – eth
    Commented Feb 15, 2018 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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