This part of the series ventures into section 4 of the Yellow Paper, to describe transactions.
Be sure to check out Part 0, if you haven't yet to get conventions right.
Transaction
As said in previous part, transactions are what that drive the ethereum state machine from one state to another. Consider a transaction,
These are cryptographically signed instructions are signed by the sender which can only be an EOA, not a contract. This may seem confusing to Solidity developers. Since a contract can also call other contract & be a sender (msg.sender
) in context of the called contract - right? Well, yes but the originator of the transaction (tx.origin
) i.e. the entity which initialized the the transaction in the first place is always an EOA. A transaction can either result in a message call to some existing contract or creation of a new contract.
Types
As of London version of the protocol there are 3 transaction types (see EIP2718 and EIP2930):
- 0 (legacy): The legacy transactions, before the introduction of the new transaction types.
- 1 (EIP2930): These transactions specify additional fields in the transaction tuple (see below).
- 2 (EIP-1559):
Transaction Anatomy
Common Fields
All transactions regardless of type/action have a number of common fields:
( ): EIP-2718 transaction type. ( ): Nonce of sender i.e. no. of transactions sent by sender ( ): Gas price of this transaction i.e wei per unit of gas paid for this transaction ( ): Max amount of gas this transaction can use. Paid up-front by sender ( ): Address of receiver. If null ( ), it is a contract creation transaction. ( ): Amount of wei to be sent to receiver or in case of contract creation, a value to newly created contract. , ( ): Values that correspond to signature of the transaction and used to verify, cryptographically, the sender of the transaction.
Type-1 & Type-2 Tx
A type-1 and type-2 transactions (i.e.
( ): List of access entries to warm-up. Each list item is a tuple . Tuple has two items - and account address and a list of storage keys, i.e. .
Notice the subscript
( ): Chain id. Must be equal to network chain id, . ( ): Y-parity of the transaction. Used to compute the value of the signature. See this.
Type-2 Tx
The gas price in transaction type-2 (
( ): Scaler value representing max amount of wei to be paid per unit of gas for execution of transaction. ( ): Scaler value representing max amount of wei paid to miner (block's fee recipient) as incentive to include the transaction in block.
Type-1 & Type-0 Tx
In contrast to max fee amounts per gas in type-2 transactions, type-0 and type-1 transactions simply specify gas price as single value:
( ): Scaler value representing amount of wei per unit gas to be paid to miner for all computation costs for execution of this transaction.
Type-0 (Legacy) Tx
The legacy (
( ): A scalar value that encodes ( ) and, if present, the ( ). So,
See EIP-155.
Contract Creation Tx
If the transaction is a contract creation transaction, it also contains:
( ): The byte array specifying initialization process of contract. You might know it as the creation bytecode fragment of the contract bytecode.
Keep in mind that in contract creation transactions
Message Call Tx
Now, if transaction is a message call transaction instead of contract creation, it has:
Let me disambiguate something for folks who've used ethereum libraries like ethers or web3.js. While creating a custom transaction object using these,
The paper defines the transaction collapse function,
where,
The
Remember from Part 0: Conventions that
There are only certain possible values each constituent of
where
The case with
The Withdrawal
The Withdrawal
( ): Incrementing unique identifier/index for this withdrawal. ( ): Validator index the withdrawal corresponds to. ( ): The recipient address that will get withdrawn Ether. ( ): Amount in wei to be denominated.
All constituents of
And this concludes this part! Next up is the section about Block stay tuned!