0

I am getting this error when i trying to use metamask on my gancache local for a simple transaction Metamask is connected to my ganache this is the erreur enter image description here

and this is how i called my methode

packItem: function (event) {
    event.preventDefault();
    var processId = parseInt($(event.target).data('id'));

    App.contracts.SupplyChain.deployed().then(function (instance) {
        return instance.packItem(App.upc, { from: App.metamaskAccountID });
    }).then(function (result) {
        $("#ftc-item").text(result);
        console.log('packItem', result);
    }).catch(function (err) {
        console.log(err.message);
    });
},
3
  • Looks like the smart contract is returning an error?
    – yangli-io
    Commented Jul 8, 2021 at 16:22
  • @yangli-io no it's a metmask erreur , i run a test for my smart contract and everything works fine
    – Rami fahd
    Commented Jul 9, 2021 at 0:08
  • Are you authenticating from metamask before calling any method? Look like you have multiple account in metamask and stuck with wrong authentication Commented Jul 9, 2021 at 2:38

1 Answer 1

0

You are using the wrong account to access "this item". this has nothing to do with Metamask or any code error.

you simply don't have the rights for a specific item on the smart contract you are calling and the contract is reverting the transaction with the error you are seeing.

It looks like a code error because web3 or the lib you are using, handles all transaction errors the same, whether it's underfunding or bad data or general assertions in the smart contract, all the same way.

1
  • exactly. apart from network configuration issues and insufficient token balance, this happens because of "require()" function in Solidity. If the condition is not satisfied, as we know, the contract reverts the transaction.
    – Sapthaka
    Commented Jan 30 at 20:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.