ERC777 - Should we use send() or transfer()

Hello, new to OpenZeppelin and to Solidity and smart contracts in general, but I’ve been a developer for over 25 years, so I know my way around.

I have been working on a project that was largely implemented and was just about fully functional. My build was based around an ERC20 token, but I learned that the ERC777 spec addressed some of the issues that made my ERC20 implementation clunky. I’ve updated the project to use the ERC777 spec and things are still working fine, but I did notice that when using the token’s send() function, MetaMask doesn’t pick up on the fact that I’m sending tokens out of the wallet.

The UI on the left uses send() and the right uses transfer()

Obviously the transfer() approach is more informative to the user, but which is more appropriate for an ERC777 token, especially a token that is being sent to ERC777 compatible contracts?

Thanks!

Hi, welcome! :wave:

Cause the ERC777 standard is backwards compatible with ERC20, so there is a function named transfer in ERC777 just like ERC20, you can use both transfer and send to move tokens from one address to another address I think, if possible, you should use send, cause this is a new feature in ERC777, it can prevent tokens from being locked forever, but it is ok if you do not use it, all depends on you.

For more details about ERC777, you can look at this documentation:

Hey thanks for the info. I’m using the OpenZeppelin base 4.0 contract … and I noted that both the transfer and send functions both call the hooks on receiving contracts. So it looks like both mechanism will work if using the OpenZeppelin contracts as a base.

I just wish the send functionality triggered the appropriate visual cues in MetaMask. Perhaps other wallet providers handle this better, but it just feels wrong to do a send when MetaMask is literally suggesting the 0 tokens are leaving the owner’s possession.

Thanks again for the help!

Yeah, you are right! The function send() just has an extra parameter data to receive the information provided by the token holder (if any).

I am not sure for this, maybe you can share your project so I can have a look.