Creating new account from web3 showing error

5 days ago

while creating new account from angular using web3

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');

@Injectable()

export class

ContractService {

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

private contAddr='0xadd2b6f750e0a05b25840ac9037365ce79f6a475';

web3:any;

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"));

}

console.log(this.web3._provider);

this.web3.eth.getAccounts((err,

accs) => {

if (err !=

null) {

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

return;

}

if (accs.length ===

0) {

alert('Couldn\'t get any accounts! Make sure your Ethereum client is configured c

  • 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.

    5 days ago