0

So i want to forward erc20 tokens that i receive in different wallets, to a single "parent" wallet so to speak.

by searching around the stackexchange, i found how to forward ethers,

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

but i can't seem to figure out how to do it for the erc20 tokens.

any material i can read up on or code snippets to check out would be appreciated.

Thank you very much.

1

This is not possible.

There is no payable equivalent in the ERC20 standard, so contracts receiving tokens are unaware that they have received tokens, and cannot react to it. You must sweep the tokens separately.

ERC223 proposes a token fallback system that allows contracts to receive a call when tokens are being sent to them, and react to it. I'm not aware of any major token that already implements this.

Another possibility, if your token supports it, would be to make use of approveAndCall, and have the user approve your contract to withdraw a certain amount, and then process that in receiveApproval

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.