0
votes

My Solidity Code transfer ETH is working, But ERC20 Token Not Transfer.

pragma solidity ^0.5.1;

contract Token { function transfer(address to, uint256 value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function transferFrom(address from, address to, uint256 value) public returns (bool success); }

contract General {

 mapping(uint256 => address) public userOf; 

address admin;


event SetTokenInfoEvent(uint16 tokenCode, string symbol, address tokenAddr, uint256 totaltokens);


constructor() public{
admin = 0xc8e3b905E7d462BD6368240BEC9C482b215D4147;
}




function deposit() public payable {
    require(msg.value > 0);
}

 function withdraw(uint256 amount,uint256 _cusid) public {
    require(userOf[_cusid]==msg.sender);
    require(amount > 0);
    msg.sender.transfer(amount);
}

function storecustomer(address user,uint256 _cusid) public returns(bool)
{
   require(admin == msg.sender);
  userOf[_cusid]=user;
   return true;
}



function tokenDeposit(address tokenaddr,uint256 tokenAmount) public payable
{
     Token(tokenaddr).transferFrom(msg.sender,address(this), tokenAmount);
}

//token withdraw

function tokenWithdraw(uint256 _cusid,uint16 tokenAddr,address withdrawAddr, uint256 tokenAmount) public payable
{
     require(userOf[_cusid]==msg.sender);
     Token(tokenAddr).transfer(withdrawAddr, tokenAmount);

}

}

1

1 Answers

0
votes

In tokenwithdraw function you used uint for tokenaddr that is wrong change uint to address

function tokenWithdraw(uint256 _cusid,address tokenAddr,address withdrawAddr, uint256 tokenAmount) public payable
 {
 require(userOf[_cusid]==msg.sender);
 Token(tokenAddr).transfer(withdrawAddr, tokenAmount);

}