Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

what the meaning of receiver and code of an apply function #4311

Closed
breadbread1984 opened this issue Jun 25, 2018 · 1 comment
Closed

what the meaning of receiver and code of an apply function #4311

breadbread1984 opened this issue Jun 25, 2018 · 1 comment

Comments

@breadbread1984
Copy link

breadbread1984 commented Jun 25, 2018

is the receiver the message receiver? is the code the message sender? If so, I am confused that the implement of EOSIO_ABI requires receiver == code to process the message. then only the contract account itself can send message to itself.

@wanderingbort
Copy link
Contributor

when an action is sent to the network, it specifically addresses a single contract account (the "code" account) and an action on that account. However, the contract can use require_recipient to notify another account of the action so that a contract on that account may respond. When it does this, it does not change the "code" account. This resolves any ambiguity between receiving the action "myaction" as a relay from another contract "notme" vs directly to your account "me".

In these cases
initial action is delivered to "notme" with code and receiver == "notme" then redelivered to "me" with code == "notme" and receiver == "me".

receiver should always be the name of the account the contract is running on however, as it is possible to upload the same contract to multiple accounts it is convenient to have this passed in at runtime.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants