Messages

Contracts have the ability to send “messages” to other contracts. Messages are virtual objects that are never serialized and exist only in the Ethereum execution environment. A message contains:

  • the sender of the message (implicit);
  • the recipient of the message;
  • the amount of ether to transfer alongside the message;
  • an optional data field; and
  • a STARTGAS value.

Essentially, a message is like a transaction, except it is produced by a contract and not an external actor. A message is produced when a contract currently executing code executes the CALL opcode, which produces and executes a message. Like a transaction, a message leads to the recipient account running its code. Thus, contracts can have relationships with other contracts in exactly the same way that external actors can.

Note that the gas allowance assigned by a transaction or contract applies to the total gas consumed by that transaction and all sub-executions. For example, if an external actor A sends a transaction to B with 1,000 gas; B consumes 600 gas before sending a message to C; and the internal execution of C consumes 300 gas before returning; then B can spend another 100 gas before running out of gas.

results matching ""

    No results matching ""