12

I saw the description of the function require_recipient and it says:

Add the specified account to set of accounts to be notified

I would like to understand what's the purpose of receive this notification of a transaction. What are the practical real scenarios examples for dApps that we use it?

I saw that being used on transfer action of eosio.token, I see this notification in my nodeos log but I want to understand it with more details.

1 Answer 1

13

Think of it as sending a carbon copy of the action. Since eosio.token does it with transfer, contracts can monitor and respond to deposits. e.g. if user a transfers EOS to contract b, then b could automatically transfer another token type back to a, creating a simple exchange.

3
  • Thanks Todd! Do you mind to give me a smart contract code example in how to "watch" another contract transaction? Like, how can I watch for my contract an eosio.token transfer action? May 9, 2018 at 15:19
  • 2
    Here's an example. Firefox (fastest) or Chrome (slow load): tbfleming.github.io/cib/… May 9, 2018 at 15:21
  • 1
    That's perfect my friend, things are clear now, so if I understood correctly the name of the action in my recipient contract must have the same name of the "emitter" contract and always have two parameters: uint64_t self and uint64_t code, then I execute unpack_action_data with the struct of the "emitter" contract ABI. May 9, 2018 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.