你好,我复制了etherdelta智能合同,code.All正在工作,我可以从snart合同中提取代币到我的个人钱包里。通过阅读我所理解的代码,depositToken方法就像允许契约代表me.But从我的钱包中发送令牌--这不是working.when --我单击gets时,事务将被恢复。我想批准() function.Please有一些问题,有人能帮我弄清楚吗?
function depositToken(address token, uint amount) {
//remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
if (msg.value>0 || token==0) throw;
if (!Token(token).transferFrom(msg.sender, this, amount)) throw;
tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount);
Deposit(token, msg.sender, amount, tokens[token][msg.sender]);
}//请记住调用令牌(地址).approve(此,金额),否则本合同将无法代表您进行转账。
这句话是什么意思?
发布于 2018-06-18 00:45:23
在调用approve之前,是否在令牌契约上调用depositToken函数?如果不这样做,那么transferFrom将失败,因为合同没有授权移动您的任何令牌。
https://ethereum.stackexchange.com/questions/51445
复制相似问题