0

I'm trying to call a function in my smart contract and keep getting the error Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_sendTransaction without a callback parameter I understand that I need to make the call asynchronous but am unsure how I would do this. My code is:

   mainEvent.watch(function(error, result){
        if (!error)
            {
                $("#instructor").html(result.args.addr);
                console.log(result)
            } else {
                console.log(error);
            }
    });

   $("#button").click(function() {
       console.log(Raffle.main());
   });
0

You need to provide a callback to Raffle.main. (I'm assuming that's the function it's complaining about.)

Raffle.main(function (err, result) {
    console.log(result);
});
  • Thanks, where abouts would I put this in my code? – JAG Jan 31 '18 at 0:24
  • It replaces the line console.log(Raffle.main()); – user19510 Jan 31 '18 at 0:25

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.