Last active
November 12, 2022 22:42
-
-
Save bjoveski/1784320db7a6a4879d36801871a021c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Forwarder { | |
address public destination; | |
constructor(address _destination) public { | |
destination = _destination; | |
} | |
function flushERC20(address tokenContractAddress) public { | |
IERC20 tokenContract = ERC20(tokenContractAddress); | |
uint256 forwarderBalance = tokenContract.balanceOf(address(this)); | |
tokenContract.transfer(destination, forwarderBalance); | |
} | |
} |
Hi
I tried to pay the customer via coinbase commerce with this forwarder contract but I accidentally sent it via BEP20 instead of ERC20, what needs to be done now in order to flush the ETH PEG tokens to the merchant final address?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This part is a bit complicated.
All interactions Coinbase has are through the factory contract. The first time you pay to an address, that factory will create a Forwarder & flush the ERC20 token indicated in the argument. The second time you pay to the same address, the factory will call a different method that will just flush the tokens (again, the token is indicated in the argument).
This is also made a bit more difficult, since you are actually calling the original Forwarder and not the proxy copies; so the tx logs might look funky at a first glance.
ETH is handled differently from the ERC20 tokens.