Transactions and messages are fundamental concepts within the Ethereum ecosystem. While they appear similar in structure, they serve distinct purposes and operate under different rules. This article clarifies the differences between transactions, messages, and message calls, providing a clear overview of their roles and technical characteristics.
What Is an Ethereum Transaction?
A transaction refers to a cryptographically signed data package initiated by an external actor (such as a user) and broadcast to the Ethereum network. It facilitates the transfer of value or data between accounts and can trigger smart contract functions or even create new contracts.
A valid Ethereum transaction includes the following components:
- Recipient address
- Digital signature (verifying sender identity)
- Value (amount of Ether being sent, denominated in wei)
- Optional data field
- STARTGAS value
- GASPRICE value
There are two primary types of transactions:
- Those that trigger message calls between accounts or contracts
- Those that result in the creation of new contract accounts
Key Transaction Fields
According to the Ethereum Yellow Paper, a standard transaction consists of these fields:
- Nonce: A sequence number issued by the sender’s account to prevent replay attacks.
- GasPrice: The price per unit of gas, denoted in Ether.
- GasLimit: The maximum amount of gas allowed for transaction execution.
- To: The recipient’s address (for account or contract transactions).
- Value: The amount of Ether to transfer, in wei.
- V, R, S: Components of the elliptic curve signature used to recover the sender’s public key and address.
For contract creation transactions, the following fields are also included:
- Init: EVM (Ethereum Virtual Machine) bytecode for initializing the contract.
- Data: An optional field containing input data (the size is practically unlimited).
What Is a Message?
A message is a virtual object generated internally within the Ethereum network—typically by a smart contract. Unlike transactions, messages are not directly signed by external users and are not permanently recorded on the blockchain.
A message usually contains:
- Sender address
- Recipient address
- Value (amount of Ether, in wei)
- Optional data payload
- STARTGAS limit
- GASPRICE value
Messages can be understood as function calls within the EVM. They facilitate communication between contracts and enable complex, interoperable logic across decentralized applications.
Differences Between Transactions, Messages, and Message Calls
The Ethereum Yellow Paper offers formal definitions for these terms:
Transaction: “A piece of data, signed by an External Actor. It represents either a Message or a new Autonomous Object. Transactions are recorded into each block of the blockchain.”
Message: “Data (as a set of bytes) and Value (specified as Ether) that is passed between two Accounts, either through the deterministic operation of an Autonomous Object or the cryptographically secure signature of the Transaction.”
Message Call: “The act of passing a message from one Account to another. If the destination account is associated with non-empty EVM Code, then the VM will be started with the state of said Object and the Message acted upon.”
In practical terms:
- A transaction requires an external signature, is broadcast network-wide, and after miner validation, is permanently stored in a block.
- A message is generated internally by a contract, is not broadcast, and does not require a signature.
- A message call refers to the execution of a message. It is a local, read-only operation that does not consume Ether and reverts to the original state after execution.
👉 Explore real-time transaction tools
Are Contract Function Calls Treated as Transactions or Messages?
Consider the following scenarios:
- Directly calling a contract function using
call - Using
sendTransactionto invoke a contract function - Calling a contract function from another contract using
call - Using
sendTransactionto call a contract function from another contract
Cases 1 and 3 are message calls—they are internal, read-only, and do not alter blockchain state. Case 2 creates a transaction since it uses a method intended for external signing and broadcasting.
Case 4 is more nuanced. Although sendTransaction is used, the call originates from a contract rather than an external actor. According to the Yellow Paper, a transaction must be signed by an external actor. Thus, this scenario does not qualify as a transaction.
Frequently Asked Questions
What is the main functional difference between a transaction and a message?
Transactions are signed, broadcasted, and permanently recorded on-chain. Messages are internal signals between contracts, not signed or stored on the blockchain.
Can a message transfer Ether like a transaction?
Yes. Messages can carry Ether value between contracts, just like transactions. However, messages are initiated by contracts rather than external accounts.
Why is gas required for transactions but not always for messages?
All transactions require gas because they modify blockchain state. Message calls that are read-only (using call) do not consume gas since they don’t alter state. However, messages that change state do require gas.
How do I decide between using call or sendTransaction?
Use call for read-only operations that don’t require gas. Use sendTransaction when you want to change the state of the blockchain, which requires gas and a signature.
Are messages secure?
Messages are executed within the EVM under predefined rules, making them deterministic and tamper-resistant. However, the security of a message depends on the correctness of the smart contract code.
Can messages be reversed?
Since messages are part of contract execution, they can be reverted if the overall transaction fails. Once a transaction is confirmed, however, it cannot be reversed.