因此,我想将在不同钱包中接收到的erc20令牌转发到一个“父”钱包。
通过搜索stackexchange,我找到了如何转发以太,
> pragma solidity 0.4.21;
>
> contract Forwarder {
>
> address public destinationAddress; event LogForwarded(address
> indexed sender, uint amount); event LogFlushed(address indexed
> sender, uint amount);
>
> function Forwarder() public {
> destinationAddress = msg.sender; }
>
> function() payable public {
> emit LogForwarded(msg.sender, msg.value);
> destinationAddress.transfer(msg.value); }
>
> function flush() public {
> emit LogFlushed(msg.sender, address(this).balance);
> destinationAddress.transfer(address(this).balance); }
>
> }但我似乎想不出如何为erc20令牌做这件事。
任何材料,我可以阅读或代码片段,以检查将不胜感激。
非常感谢。
发布于 2018-07-29 23:02:26
这是不可能的
在payable标准中没有ERC20等效项,因此接收令牌的合同不知道它们已经接收到令牌,因此无法对其做出反应。你必须分开清扫这些代币。
ERC223提出了一种令牌回退系统,允许合同在向其发送令牌时接收呼叫,并对其作出反应。我不知道有什么主要的令牌已经实现了这一点。
另一种可能性,如果您的令牌支持它,将是使用approveAndCall,并让用户批准您的合同提取一定的金额,然后处理在receiveApproval中。
https://ethereum.stackexchange.com/questions/55067
复制相似问题