1

My requirement is to create an eth account and do transaction.

In Web 0.20.0 I am able to create web3.personal.newAccount and able to get create contract object. When I am using that created contract object to call methods I am getting HTTP synchronous not supported. I am using a test private network.

In Web 1.0.0 I am not able to create account but I can get a contract and call its methods.

Can you help me how I can achieve both.

My code snippet

 var data=web3.eth.accounts.create(web3.utils.randomHex(32));
 alert("Response"+JSON.stringify(res));

or

  web3.eth.accounts.create(web3.utils.randomHex(32),function(err,res){         
     if(err){
       alert("creating account error "+err);                   
     }else{
       alert("creating account success "+JSON.stringify(res));                   
     }
  })
1
  • 4
    Share your code. Chances are you simply need to add an error first callback function to your Web3 calls to make them asynchronous Commented Jun 25, 2018 at 7:34

1 Answer 1

0

As per web1.0 API document use web3.eth.personal.newAccount() for create new account. API document is not updated for getAccounts, unlockAccount, lockAccount, sendTransaction, but it will work.

web3.eth.personal.newAccount("Password", function(err, result){
   if(err){
       alert("Error"+ err);
       return;
   }
   alert("Account address: "+ result);
});

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.