0

我的 Solidity 代码转移 ETH 工作正常,但 ERC20 代币无法转移。

pragma 可靠性 ^0.5.1;

contract Token { function transfer(address to, uint256 value) public 返回(bool 成功);函数批准(地址_spender,uint256 _value)公共返回(布尔成功);function transferFrom(address from, address to, uint256 value) public 返回(bool 成功);}

合同一般{

 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);

}

}

4

1 回答 1

0

在 tokenwithdraw 函数中,您将 uint 用于 tokenaddr,这是错误的,将 uint 更改为地址

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

}
于 2019-05-30T07:34:39.683 回答