4

I want to create a new account over IPC so I have started private chain with the below command

geth --networkid=5 --datadir DataDir --ipcapi "db,eth,net,web3,personal" --ipcpath "/Users/smartSense/.ethereum/geth.ipc"
--rpc -rpcapi "eth,web3" --rpcaddr=localhost --rpcport=8545 --rpccorsdomain "*" console 2>geth.log 

now I'm trying to create new account with web3 api Ref. Link : Link

var options = {
    host: '/Users/smartSense/.ethereum/geth.ipc',
    ipc:true,
    personal: true,
    admin: false,
    debug: false
};

var web3Extended = web3_extended.create(options);
web3Extended.personal.newAccount("password",function(error,result){
        if (!error)
            res.send(result);
        else
            res.send("error"+error);
});

but I got below error:

errorError: Invalid JSON RPC response: "Error: connect ECONNREFUSED 127.0.0.1:80\n    at Object.exports._errnoException (util.js:1022:11)
\n    at exports._exceptionWithHostPort (util.js:1045:20)\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)"

over RPC I have created successfully but over IPC i got error so any one have idea about that?

  • 1
    Try using this var web3 = new Web3(new Web3.providers.IpcProvider('/Users/myuser/Library/Ethereum/geth.ipc', net)); – Aniket Jul 20 '18 at 18:03
0

Require web3_ipc instead of web3_extended.

const web3_extended = require('web3_ipc');

Also, make sure your geth.ipc location is right. Mine (Mac OS X) was on ~/Library/Ethereum/geth.ipc.

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.