I am playing around with Metamask and the web3.js API using the Google Chrome console. However, I have two issues:
1) I am trying to send a simple transaction using Ganache GUI (localhost 7545) and I am entering the code below:
> ethereum.enable()
> web3.currentProvider.selectedAddress
<."0xb8662b66584ae08a88341df0d2b3fa7a65eb158c"
> var transaction = {
from: web3.currentProvider.selectedAddress,
to: "0xA8b62F503181D9A56683129de1B98ea4Bf143a40",
value: web3.toWei("1", "ether")
}
> web3.eth.sendTransaction(transaction)
Then I am getting the error message below:
> Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_sendTransaction 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.
at MetamaskInpageProvider._sendSync (inpage.js:1)
at MetamaskInpageProvider.send (inpage.js:1)
at Proxy.t.send (inpage.js:1)
at a.send (inpage.js:1)
at w.e [as sendTransaction] (inpage.js:1)
at <anonymous>:1:10
2) Also note that the web3.version
seems to be 0.20.7 whereas when I check this website https://web3js.readthedocs.io/en/v1.2.4/, the new version of the web3.js API seem to be 1.2.4. Is there a way to update the web3.js API version in the chrome console while using the Metamask extension?
Note that I have tried to enter this in the console web3 = new Web3(web3.currentProvider)
but the web3.version
remains 0.20.7.
In terms of priority 1) is more critical I believe.
Could you please assist.
Thank you