我的Solidity Code传输ETH正在运行,但是ERC20令牌无法传输。
pragma solidity ^ 0.5.1;
合约代币{ 函数传递(地址到uint256值)公共返回(布尔成功); 函数批准(地址_spender,uint256 _value)公共返回(布尔成功); 函数transferFrom(address from,address to,uint256 value)公共返回(布尔成功); }
总承包商{
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);
}
}
答案 0 :(得分: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);
}