title: ERC20: transfer amount exceeds allowance Smart contract with brownie and NFT
body: <p>Hello there I have two smart contracts, one is an ERC1155 contract which mints a NFT from Moralis IPFS server, the other is a ERC20 token. I want users to be able to pay for the minted NFT using the ERC20 token but I'm receiving an error on the <code>transferfrom()</code> function:  brownie.exceptions.VirtualMachineError: revert: ERC20: transfer amount exceeds allowance. I did some research but nothing helped so far.</p>
  <p><a href="https://i.stack.imgur.com/D0AkB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D0AkB.png" alt="error from terminal" /></a></p>
  <p>This is my ERC1155 contract</p>
  <pre class="lang-js prettyprint-override"><code>
  import &quot;@openzeppelin/contracts/token/ERC1155/ERC1155.sol&quot;;
  import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;
  // import &quot;@openzeppelin/contracts/utils/math/SafeMath.sol&quot;;
  import &quot;@openzeppelin/contracts/token/ERC20/IERC20.sol&quot;;
  import &quot;@chainlink/contracts/src/v0.8/VRFConsumerBase.sol&quot;;
  
  contract NFTPomoBots is ERC1155, Ownable {
      IERC20 private _roboToken;
  
      constructor(IERC20 roboToken)
          ERC1155(
              &quot;ipfs://QmcPjTnt33BRM5TPGyno7restoftheurl/({id}.json&quot;
          )
      {
          _roboToken = roboToken;
      }
  
      function mintPomoBot(
          address account,
          uint256 id,
          uint256 amount
      ) public {
          require(_roboToken.transferFrom(msg.sender, address(this), 1));
          _mint(account, id, amount, &quot;&quot;);
      }
  }
  
  </code></pre>
  <p>this is the ERC20 contract</p>
  <pre class="lang-js prettyprint-override"><code>// SPDX-License-Identifier: MIT
  
  import &quot;@openzeppelin/contracts/token/ERC20/ERC20.sol&quot;;
  import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;
  import &quot;@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol&quot;;
  
  pragma solidity ^0.8.0;
  
  contract RoboToken is ERC20, Ownable {
      uint256 public maxSupply = 100000 * 10**18;
  
      constructor() ERC20(&quot;Pomobots Token&quot;, &quot;POMO&quot;) {
          _mint(msg.sender, maxSupply);
      }
  
      function transferToAccount(
          address to,
          uint256 amount,
          bool completedTime
      ) public onlyOwner {
          require(completedTime == true);
          _mint(to, amount);
      }
  
      function approveNFTContract(address _tokenAddress) public onlyOwner {
          approve(_tokenAddress, maxSupply);
      }
  }
  
  </code></pre>
  <p>this is the test script</p>
  <pre class="lang-py prettyprint-override"><code>def test_can_mint_new_nft():
  
      # Arrange
      account1 = get_account()
      print(f&quot;account 1 {account1.address}&quot;)
      account2 = get_account(1)
      print(f&quot;account 2 {account2.address}&quot;)
  
      robo_token = deploy_erc20_token()
      pomobot_token = NFTPomoBots.deploy(robo_token, {&quot;from&quot;: account1})
      # Act
      tx1 = robo_token.transferToAccount(account2, 10, True)
      tx1.wait(1)
  
      print(robo_token.balanceOf(account2.address))
      tx2 = robo_token.approve(account2.address, robo_token.balanceOf(account2.address))
      tx2.wait(1)
  
      # assert
      assert pomobot_token.mintPomoBot(account2.address, 20, 1, {&quot;from&quot;: account2})
      print(f&quot;nft minted to {account2.address}&quot;)
      print(robo_token.balanceOf(account2.address))
  
  </code></pre>
  <p>Any help is appreciated, also should I make the function minPomobot() payable?</p>