I have a simple Vue form, that calls a method in an Ethereum contract. If I don't provide a callback to my method, Metamask complains:

Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_sendTransaction without a callback parameter.

So I added this. (even though I already have a callback in my sendTransaction)

Then I get the error:

Uncaught TypeError: Cannot read property 'sendTransaction' of undefined

In my console.log I can clearly see the method on dash.crowdsaleContractInstance, and the sendTransaction property as well.

I'm using Ganache CLI v6.7.0 (ganache-core: 2.8.0) and metamask web3 api version: 0.20.7

Im calling my method on the instance of the contract not the contract object

I tried this as well as found in the documentation: myContract.methods.myMethod(123).send... but the methods property is not available, so I guess I'm on another version of web3?

I've done a fair share of web3 smart contract programming by now, but I still find it very hard to debug, to be honest. Anybody who can help to find what is going wrong here?

dash is an object where I instantiate a lot of async functionality


vmBuyform = new Vue({
el: '#buyForm',
data: {
  to: dash.crowdsaleaddress,
  from: accounts[0],
  amount: 0.25
methods: {
  buy: function (event) {

    var sender = this.from;
    var receiver = this.to;
    var amountVal = this.amount;

    var amount = web3.toWei(amountVal, 'ether');
    console.log('Version: ', web3.version);

    // does not work with metamask enabled, works without metamask
    dash.crowdsaleContractInstance.depositFunds({from:sender, to:receiver, value: amount, gas: 2000000},
      function(error, result){}).sendTransaction({from:sender, to:receiver, value: amount, gas: 2000000},function(error, result){



  • "so I guess I'm on another version of web3?" - Correct, if the methods property is not available, then you're using web3.js v0.x. The official documentation for this version is here. I recommend switching to v1.2.1 or higher, but not higher than the highest v1.x. – goodvibration Nov 27 '19 at 14:14
  • How web3 is create? How dash.crowdsaleContractInstance is created? – Ismael Nov 27 '19 at 15:13
  • Solved, the problem was something else... in the contract coins were send, but the sender address had an empty balance. – hdries Nov 27 '19 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.