Search code examples
node.jsvisual-studio-codeweb3js

Creating an account in web3.js without running geth?


I want to Know about How to create a new personal account,How to do mining for that account and How to do Send Transaction from that account using web3.js?.I tried to create new account using(web3.eth.personal.newAccount()) in web3.js by connecting with the geth. But I want to do create an account,Mining and Send Transaction in web3.js without running geth?.I am following web3:1.0.0-beta.33 version document.Is it possible to do all these without running geth? My code is

    var Web3 = require('web3');
    var web3 = new Web3(new 
    Web3.providers.HttpProvider('http://xx.xx.xx.xxx:xxxx'));
    web3.setProvider(new 
    Web3.providers.WebsocketProvider('ws://xx.xx.xx.xxx:xxxx'));
    var net = require('net');
    var web3 = new Web3(new 
    Web3.providers.IpcProvider('\\\\.\\pipe\\geth.ipc', net));
    var Web3EthPersonal = require('web3-eth-personal');
    var personal = new Web3EthPersonal('http://xx.xx.xx.xxx:xxxx');

    web3.eth.personal.newAccount('test123',function(error , response){
    if(!error){

    console.log(response);
    }else{
        console.log(error);

    }
    });

Solution

  • You can create accounts and submit transactions without running a local node by using a 3rd party provider like Infura. They have plenty of documentation on their site about how to create an API key and integrate with their node cluster.

    But, you need to have a node running in order to mine.