'How to solve insufficient allawance issue when calling transferFrom? web3.js

I'm struggling with the trasferFrom method of my standad ERC20 contract. I'm working with web3.js and INFURA I have wallet1 with 50 token allowance, now if I call my function I've always same error "ERC20: insufficient allowance". This is my code

 let data = await contract.methods.transferFrom(from, to, qta).encodeABI();
 let nGas = web3.utils.toHex(100000);

  let txObj = {
    "gas": nGas,
    "to": CONTRACT_ADDRESS,
    "value": 0x0,
    "data": data,
    "from": wallet1
  }
  
  await web3.eth.accounts.signTransaction(txObj, PRIVATE_KEY, function(err, signedTx) {
    if (err)
      document.getElementById("ret").innerText = err;
    else
    {
      web3.eth.sendSignedTransaction(signedTx.rawTransaction, function(err, res) {
        if (err)
          document.getElementById("ret").innerText = err;
        else{
          document.getElementById("ret").innerHTML = "<a href=\"https://ropsten.etherscan.io/tx/" + res + "\" target=\"_blank\">etherscan</a>";
        }
      });
    }
  });

I've tried with

 await contratto.methods.transferFrom(from, to, qta).call({ from: wallet });

it doesn't work. Also with .send instead of .call...same result...doesn't work Anyone has any suggestion? Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source