In Ethereum, every action that changes the blockchain’s state is initiated through a transaction. There are two primary types of transactions:
- Contract Creation Transaction – used to deploy a new smart contract on the blockchain.
- Message Call Transaction – used to invoke an existing contract’s function or to send Ether between accounts.
2. Contract Creation Transaction
A Contract Creation Transaction is triggered when a user wants to deploy a new smart contract.
Required Parameters:
- Sender Address
- Nonce
- Gas & Gas Price
- Value (Endowment in Wei)
- Init Code (EVM code for deployment)
Working:
- The init code is executed once and returns the contract’s runtime code.
- A new contract address is created using:
Keccak256(sender + nonce) → last 20 bytes → new contract address - If successful, the runtime code is stored at the new address.
- If an error (like out-of-gas), the contract is not created, and state reverts.
3. Message Call Transaction
A Message Call Transaction is used to:
- Transfer Ether between accounts, or
- Call a function inside an existing smart contract.
Required Parameters:
- Sender and Recipient Address
- Gas & Gas Price
- Value (in Wei)
- Input Data (function selector + parameters)
Working:
- The transaction sends input data to the contract.
- If the contract has code, it gets executed.
- If successful, state changes (e.g., data stored, balances updated).
- It can also return data or trigger internal calls to other contracts.
4. Differences between Contract Creation and Message Call
Feature | Contract Creation | Message Call |
---|---|---|
Purpose | Deploy a new contract | Call existing contract or transfer ETH |
Address | New address generated (Keccak hash) | Uses existing contract address |
Code Executed | Init code (creates runtime code) | Runtime code of the contract |
Returns | New contract address (if successful) | Execution result/output (if any) |
State Change | Yes | Yes |
