Seems like maybe it would have been good if the ERC-20 standard had been designed such that you couldn’t send the token to an address controlled by a smart contract unless the smart contract had marked itself as being able to receive that kind of ERC-20 token (or as being able to receive all kinds of ERC-20 tokens)
Like, if the contract for the ERC-20 token would, when handling a send instruction, would check whether the recipient address was a contract address or an address controlled by a keypair, and if the former, would check if the recipient had been marked (not sure if this marking would be stored as data on the recipient contract or as data on the ERC-20 contract) as being able to handle the token in question, and if not, cancel the transaction (other than gas costs).
This seems like it would prevent this kind of error (or at least, reduce the problems resulting from this kind of error to just paying the gas fees), but it would also maybe increase the gas cost of sending transactions with the ERC-20 tokens and I’m not sure whether this increased cost would be negligible or not.
Like, if the contract for the ERC-20 token would, when handling a send instruction, would check whether the recipient address was a contract address or an address controlled by a keypair, and if the former, would check if the recipient had been marked (not sure if this marking would be stored as data on the recipient contract or as data on the ERC-20 contract) as being able to handle the token in question, and if not, cancel the transaction (other than gas costs).
This seems like it would prevent this kind of error (or at least, reduce the problems resulting from this kind of error to just paying the gas fees), but it would also maybe increase the gas cost of sending transactions with the ERC-20 tokens and I’m not sure whether this increased cost would be negligible or not.