Transactions
An Ethereum transaction refers to an action initiated by an externally-owned account ( in other words an account managed by a human, not a contract.) that updates the state of the network. For example, if Bob sends Alice 1 ETH, Bob's account must be debited and Alice's must be credited. This state-changing action takes place within a transaction.
This is the only way to update the state of the Ethereum blockchain.
A world state is a snapshot of the current state of the Ethereum network, including all accounts, balances, and smart contract code. A world state transaction is a signed message that contains instructions for updating the world state.
The image shows two world states, one labeled (t) and one labeled (t+1). The transaction between the two world states updates the world state from (t) to (t+1).
The transaction itself is not shown in the image, but it is typically located somewhere between the two world states.
Here is a simplified example of a world-state transaction:
Transaction:
Sender: 0x1234567890ABCDEF
Recipient: 0x9876543210FEDCBA
Value: 1 ETH
World state (t):
0x1234567890ABCDEF: 10 ETH
0x9876543210FEDCBA: 5 ETH
World state (t+1):
0x1234567890ABCDEF: 9 ETH
0x9876543210FEDCBA: 6 ETHThis transaction transfers 1 ETH from a sender 0x1234567890ABCDEF to recipient 0x9876543210FEDCBA. The world state before the transaction is shown in World state (t), and the world state after the transaction is shown in World state (t+1).
Ethereum Transaction Object
A submitted transaction includes the following information:
from– the address of the sender, that will be signing the transaction. This will be an externally-owned account as contract accounts cannot send transactions.recipient– The Ethereum address receiving the transaction. This can be another user's address or the address of a smart contract. (if an externally owned account, the transaction will transfer value. If a contract account, the transaction will execute the contract code)signature– Sender's identifier, generated by their private key to authorize the transaction.nonce- a sequentially incrementing counter which indicates the transaction number from the accountvalue– the amount of ETH to transfer from sender to recipient.input data– an optional field to include arbitrary data.gasLimit– Maximum gas units allowed for the transaction.maxPriorityFeePerGas- the maximum price of the consumed gas to be included as a tip to the validatormaxFeePerGas- the maximum fee per unit of gas willing to be paid for the transaction (inclusive ofbaseFeePerGasandmaxPriorityFeePerGas)
The transaction object will look a little like this:
{
from: "0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8",
to: "0xac03bb73b6a9e108530aff4df5077c2b3d481e5a",
gasLimit: "21000",
maxFeePerGas: "300",
maxPriorityFeePerGas: "10",
nonce: "0",
value: "10000000000"
}However, a transaction object needs to be signed using the sender's private key. This proves that the transaction could only have come from the sender and was not sent fraudulently.
An Ethereum client like Geth will handle this signing process.
Example JSON-RPC call:
{
"id": 2,
"jsonrpc": "2.0",
"method": "account_signTransaction",
"params": [
{
"from": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db",
"gas": "0x55555",
"maxFeePerGas": "0x1234",
"maxPriorityFeePerGas": "0x1234",
"input": "0xabcd",
"nonce": "0x0",
"to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
"value": "0x1234"
}
]
}Example response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"raw": "0xf88380018203339407a565b7ed7d7a678680a4c162885bedbb695fe080a44401a6e4000000000000000000000000000000000000000000000000000000000000001226a0223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20ea02aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
"tx": {
"nonce": "0x0",
"maxFeePerGas": "0x1234",
"maxPriorityFeePerGas": "0x1234",
"gas": "0x55555",
"to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
"value": "0x1234",
"input": "0xabcd",
"v": "0x26",
"r": "0x223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20e",
"s": "0x2aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
"hash": "0xeba2df809e7a612a0a0d444ccfa5c839624bdc00dd29e3340d46df3870f8a30e"
}
}
}
With the signature hash, the transaction can be cryptographically proven that it came from the sender and submitted to the network.
Types of transactions
On Ethereum, there are a few different types of transactions:
Regular transactions: a transaction from one account to another.
Contract deployment transactions: a transaction without a 'to' address, where the data field is used for the contract code.
Execution of a contract: a transaction that interacts with a deployed smart contract. In this case, 'to' address is the smart contract address.
Transactions must always originate from an EOA.
There are two types of accounts in Ethereum: Externally Owned Accounts (EOA) and Contract Accounts. An EOA is controlled by a private key, has no associated code, and can send transactions. A contract account has an associated code that executes when it receives a transaction from an EOA. A contract account cannot initiate transactions on its own. Transactions must always originate from an EOA.
Transactions are cryptographically signed instructions from accounts. An account will initiate a transaction to update the state of the Ethereum network. The simplest transaction is transferring ETH from one account to another.
Last updated
