0

This is a BSC address but I noticed people are able to send tokens to a smart contract address. I thought only wallets can receive compatible tokens:

https://bscscan.com/address/0x37ee638d85e420532e35cd9dd831166514855e6d#code

Does this mean one can send compatible tokens to any smart contract address and the contract will get a "token received event" triggered?

1

In general, you can send tokens to any address and it will go through. The only exceptions are if the token implements safeTransfer functionality, which first makes sure that the receiving address is capable of handling the tokens - but most tokens don't include such safety measures.

Furthermore, contracts have no idea when they have received tokens, and therefore there is no "token received event".

The problem with detecting token transfers is that a token transfer is not an explicity transfer at all - it's simply a function call to the token contract which instructs the contract to modify its internal ledger which says which address owns how many tokens. So the token contract doesn't consult the receiver address at all and doesn't inform anyone (on-chain) that an address has received tokens.

3
  • Thanks a lot. So if they implement safeTransfer then it means they keep proper book keeping? It's a bit confusing how someone is able to do that. I thought the person was doing the exact same thing as if he provided liquidity to a pool using the UI provided by that smart contract. So not sure how he is able to claim the sent tokens afterwards. Because I read before that you might not be able to recover your tokens if you left them in a smart contract.
    – Joan Venge
    Jun 3 at 11:11
  • I'm sorry but you're mixing up rather many concepts here. Please post a new question if you have further questions - or better still, search for existing answers to the same questions Jun 3 at 11:14
  • OK will do. thx alot.
    – Joan Venge
    Jun 3 at 11:14
1

To add to Lauri Peltonen, the smart contract that own new token must have a function that allow him to handle this token, if not they are lost.

1
  • Thanks so you mean if they don't have this function, not even the owner of the contract can recover it?
    – Joan Venge
    Jun 3 at 11:11

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.