1

I want to write a contract that uses USDT (Tether) for payment.

How can I use the ERC20 token as an ERC777 token, for example:

  • Use a fallback function that executes when we receive USDT token.
  • Or use some data while sendeing token to be processed by the receiver contract.

Is there any way like using Tether contract address in our new contract and extending its capablities?

I also saw this question, but this is about developing a new token, not an existing one.

2

With ERC-20 you cannot do this. You cannot extend the capabilities of an existing smart contract, especially if it is owned by a third party.

ERC-777 specifies a token receive interface that smart contracts can implement. A receiving smart contract implements ERC777TokensRecipient interface and can react to incoming ERC-777 send() calls.

A tutorial:

https://forum.openzeppelin.com/t/simple-erc777-token-example/746

An example implementation in production:

https://github.com/Dawn-Protocol/dawn-erc20-erc777/blob/master/contracts/Staking.sol#L243

Currently no stablecoin implements ERC-777. However many of stablecoin contracts are upgradeable, so we might see this in near future. For this, you need to inquiry the stablecoin authors themselves and public forums cannot comment their roadmap.

The another question you probably think in your head is "why ERC-20 is such crap?" In the original proposal was dicussion for transferAndCall function and we would not have this terrible UX situation what we have today. However in the end it was dropped on the preference of simplicity and security. And no one used smart contracts back in the day any case. There has been multiple competing proposal to address the issue, but due to decentralised finance smart contract being overly lax about this, it has resulted things like dForce $25M hack. People who are not technically insightul, do not care deFi and keep using centralised exchanges want to stick to the ERC-20.

| improve this answer | |

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.