title: How can I transfer ERC20 token by another smart contract?
body: <p>I have designed an erc20 token and a smart contract to transfer that token, but when I trigger the function to transfer, the remix told me the following graph.</p>
  <p><a href="https://i.stack.imgur.com/pboUm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pboUm.png" alt="enter image description here" /></a></p>
  <p>What I did was to deploy the token smart contract and then the DAO smart contract, then call the creatSubDAO function to start the transfer.</p>
  <p>The relative code is below:</p>
  <pre><code>// SPDX-License-Identifier: GPL-3.0
   pragma solidity &gt;=0.7.0 &lt;0.9.0;
  
  
  interface IERC20 {
  
  function totalSupply() external view returns (uint256);
  function balanceOf(address account) external view returns (uint256);
  function allowance(address owner, address spender) external view returns (uint256);
  
  function transfer(address recipient, uint256 amount) external returns (bool);
  function approve(address spender, uint256 amount) external returns (bool);
  function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
  
  
  event Transfer(address indexed from, address indexed to, uint256 value);
  event Approval(address indexed owner, address indexed spender, uint256 value);
  }
  </code></pre>
  <p>contract Dtoken:</p>
  <pre><code>contract Dtoken is IERC20{
  
  string public name = &quot;DAO Token&quot;;
  string public symbol = &quot;D&quot;;
  uint256 public totalSupply = 1000000000000000000000000;
  uint8 public decimals = 18;
  
  mapping(address =&gt; uint256) public balanceOf;
  mapping(address =&gt; mapping(address =&gt; uint256)) public allowance;
  
  constructor() {
      balanceOf[msg.sender] = totalSupply;
  }
  
  function transfer(address _to, uint256 _value) public returns (bool success) {
      require(balanceOf[msg.sender] &gt;= _value);
      balanceOf[msg.sender] -= _value;
      balanceOf[_to] += _value;
      emit Transfer(msg.sender, _to, _value);
      return true;
  }
  
  function approve(address _spender, uint256 _value) public returns (bool success) {
      allowance[msg.sender][_spender] = _value;
      emit Approval(msg.sender, _spender, _value);
      return true;
  }
  
  function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
      require(_value &lt;= balanceOf[_from]);
      require(_value &lt;= allowance[_from][msg.sender]);
      balanceOf[_from] -= _value;
      balanceOf[_to] += _value;
      allowance[_from][msg.sender] -= _value;
      emit Transfer(_from, _to, _value);
      return true;
     }
   }
  </code></pre>
  <p>contract MasterDao:</p>
  <pre><code>import &quot;./Dtoken.sol&quot;;
  
  contract MasterDAO {
  
  uint proposalNum;
  
  mapping (address =&gt; Member) public members;
  mapping (uint =&gt; Proposal) public proposals;
  mapping (uint =&gt; SubDAO) public subDAOs;
  // SubDAO[] public subDAOs;
  
  function createSubDAO (uint _poolGap, uint _DAOID, uint _rate, Dtoken _token) public returns (address daoAddress) {
      SubDAO subDAO = new SubDAO(_poolGap, _DAOID, msg.sender, _rate, this, _token);
      daoAddress = address(subDAO);
  }} 
  </code></pre>
  <p>SubDao Contract:</p>
  <pre><code> contract SubDAO {
  
  uint proposalNum;
  address lender;
  uint poolGap;
  uint currentStake;
  uint256 public DAOID;
  MasterDAO master;
  address stakeItem;
  uint rate;
  Dtoken public token;
  
  mapping(address =&gt; Member) members;
  mapping (uint =&gt; Proposal) public proposals;
  
  string[] description;
  
  event Transfrom(address, uint);
  
  struct Member {
      address memberAddress;
      string nickName;
      bool alreadyExist;
  }
  
  
  struct Proposal {
      string description;
      address payable recipient;
      bool executed;
      uint proposalID;
      address[] agreeMembers;
      address[] disagreeMembers;
      bool exectuable;
      uint amount;
      Dtoken token;
  }
  
  modifier membership (MasterDAO masterDAO, address _staker){
      require(masterDAO.addressExist(_staker) == true);
      _;
  }
  
  modifier lenderLimit {
      require(msg.sender == lender);
      _;
  }
  
  modifier balanceLimit(uint amount) {
      require(amount &lt;= poolGap - currentStake);
      _;
  }
  
  constructor (uint _poolGap, uint _DAOID, address _lender, uint _rate, MasterDAO caller, Dtoken _token) {
      currentStake = 0;
      poolGap = _poolGap;
      DAOID = _DAOID;
      lender = _lender;
      master = caller;
      rate = _rate;
      token = _token;
      token.transferFrom(address(this), address(this), 10);
  }
  </code></pre>
  <p>Did I do anything wrong to transfer the token? Thanks!</p>