I am deploying a contract today.
Tomorrow if some user mistakenly sends ETH to my contract, I can retrieve or return it if I have implemented a payable and a send function.
# a basic payable to enable receiving incoming eth
log ethReceived(msg.value, msg.sender)
def withdraw(_to: address):
# for sending out any eth transferred in by mistake
assert msg.sender == self.owner
log ethSent(self.balance, msg.sender)
But what if some user mistakenly sends any other ERC-20 token or ERC-721 NFT to my contract; is there a general function I could have implemented in my contract, so I can retrieve those, as long as they follow their respective standards? I won't know the token contract in advance, it could be any valid ERC-20 or ERC-721.
Vyper code preferred, but Solidity answers or examples are also fine.