2

im using web3j with angular 5 connection working perfectly and balance showing perfectly. but when i write transfer function it throw error

var tx = this._web3.eth.sendTransaction({ 
  from: this._account,
  gasPrice: "20000000000",
  gas: "21000",
  to: textetheraddress, 
  value: textetheramount,
  data: ""
 }).then(function(err, transactionHash) {
  if (!err)
    console.log(transactionHash); 
});

error

ERROR Error: The MetaMask Web3 object does not support synchronous methods like personal_newAccount without a callback parameter. See https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client for details.

0

You are trying to make a synchronous call and expect to receive a promise.

It's probably just exactly as the error says:

Usually, to make a method call asynchronous, add a callback as the last argument to a synchronous method. See the Ethereum wiki on "using callbacks"(https://github.com/ethereum/wiki/wiki/JavaScript-API#using-callbacks)

Since sync functions are not supported you need to use the async one.

So I suppose in this case your code needs to pass a callback instead of waiting for a promise and should look something like this:

var tx = this._web3.eth.sendTransaction({ 
  from: this._account,
  gasPrice: "20000000000",
  gas: "21000",
  to: textetheraddress, 
  value: textetheramount,
  data: ""
 }, function(err, transactionHash) {
  if (!err)
    console.log(transactionHash); 
})

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.