我在名为'gameDeposit'的智能合约中有一个应付款功能,用户需要存入eth才能参与游戏,但是当我使用web3 javascript API调用它时它给了我未捕获的错误
inpage.js:1 Uncaught (in promise) Error: The MetaMask Web3 object does not support synchronous methods like eth_sendTransaction without a callback parameter
const Abi = [{ABI}];
const contractAbi = web3.eth.contract(Abi);
const myContract = contractAbi.at("0x3....");
const amountEth = '0.01';
console.log(myContract);
const gameID = '10';
myContract.gameDeposit(gameID).send({
from: web3.eth.accounts[0],
value: web3.toWei(amountEth, 'ether')
},(error , result) => {
if(!error)
console.log(result);
else
console.error(error)
})
})