What are Contract Creation Transactions and Message Call Transactions? Explain with a suitable diagram.

In Ethereum, every action that changes the blockchain’s state is initiated through a transaction. There are two primary types of transactions:

  1. Contract Creation Transaction – used to deploy a new smart contract on the blockchain.
  2. 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

FeatureContract CreationMessage Call
PurposeDeploy a new contractCall existing contract or transfer ETH
AddressNew address generated (Keccak hash)Uses existing contract address
Code ExecutedInit code (creates runtime code)Runtime code of the contract
ReturnsNew contract address (if successful)Execution result/output (if any)
State ChangeYesYes

Leave a Reply

Your email address will not be published. Required fields are marked *