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.

11

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.

  • 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? – Leo Ribeiro May 9 '18 at 15:19
  • 2
    Here's an example. Firefox (fastest) or Chrome (slow load): tbfleming.github.io/cib/… – Todd Fleming May 9 '18 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. – Leo Ribeiro May 9 '18 at 16:35

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.