while creating new account from angular using web3

  1. personal.newAccount function() undefined

import { Injectable } from '@angular/core';

import { User } from './login/user';

const Web3=require('web3');

declare let require: any;

declare let window: any;

let tokenAbi = require('./tokenContract.json');


export class ContractService {

private contAbi=require('./tokenContract.json');

private contAddr='0xadd2b6f750e0a05b25840ac9037365ce79f6a475';


private contract:any;

constructor() {

if (typeof this.web3 !== 'undefined') {

this.web3 = new Web3(this.web3.currentProvider);

} else {

this.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));



this.web3.eth.getAccounts((err, accs) => {

if (err != null) {

alert('There was an error fetching your accounts.');



if (accs.length === 0) {

alert('Couldn\'t get any accounts! Make sure your Ethereum client is configured correctly.');




this.web3.eth.defaultAccount = accs[0];


this.contract=new this.web3.eth.Contract(this.contAbi,this.contAddr);

// console.log(this.contract.methods.greet().call({from:this.web3.eth.defaultAccount,gas:0x27100},function(error,result){

// console.log(error);

// console.log(result);

// }));


public register(user:User){




  • Hi there. Can you include the exact code you're using for this? – Richard Horrocks Apr 16 '18 at 14:15
  • Hi Richard pls check the question, I have update it – Shubhabrata Mukherjee Apr 17 '18 at 4:24

Your web3 talks to a node over RPC. If it is a geth node, the personal api is not exposed/enabled by default for security reasons.

Exercise caution.

You might enable it with geth --rpcapi eth,web3,personal in addition to your other parameters.

Hope it helps.

  • Hi Rob, still my problem is not solved, I have updated the question with the code, please check if I am going right? – Shubhabrata Mukherjee Apr 17 '18 at 4:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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