1

I have the following fragment of code that calls a contract method using web3 and for some reason when Metamask opens up and I click confirm to send the transaction, nothing happens. Metamask just keeps loading and says transaction approved. Also, the callback function isn't being executed. Why is this happening?

contractInstance.buy(price, seller, {
                    from: web3.eth.accounts[0],
                    value: price
                }, (err, txHash) => {
                    //do something
})
4
  • The code fragment isn't enough information. What happens when you view the transaction in MetaMask or if you run web3.eth.getTransaction()? Apr 18, 2018 at 20:37
  • @adamkipnis I can't get the transaction using web3 because I don't have the transaction hash in the callback and as I mentioned, metamask just says transaction approved and nothing else.
    – ninesalt
    Apr 18, 2018 at 20:53
  • When you click on the transaction after hitting "confirm", do you get taken to Etherscan? Are you connected to the correct network? Does the account you are using show it is holding ether in MetaMask? If all else fails, have you tried uninstalling and reinstalling the plugin? Also, have you tried your code using a local Ganache test node (without using MM)? Apr 18, 2018 at 23:09
  • No Im not taken to ES. I'm connected to a local ganache node and I tried using the mainnet and that doesnt work either. And yes, all the accounts I uses have ether in them. I haven't tried reinstalling the plugin because the same thing is happening with my co-workers.
    – ninesalt
    Apr 19, 2018 at 5:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.