# Transactions 101

By [0xMarko](https://paragraph.com/@0xmarko) · 2023-04-15

---

Let's dive into Ethereum transactions, gas limits, and network capacity.

How do transactions work?
-------------------------

Transactions are cryptographically signed data messages that contain a set of instructions. They enable the transfer of value and execution of smart contracts. It's a powerful concept that enables users to interact on the Ethereum network.

Users initiate transactions through wallets or dApps, which generate a data structure containing the transaction details. The data is signed with the sender's private key, ensuring authenticity.

Validators choose transactions in the mempool when creating new blocks, prioritizing those with higher gas prices.

The mempool (memory pool) is a temporary storage area for pending transactions waiting to be included in a block.

Mempool visualization - [https://txstreet.com/v/eth-btc](https://t.co/TM3hQfMfzh)

![Mempool](https://storage.googleapis.com/papyrus_images/2db97e49ad100302347b6cd64ecdf2677a7c376175771ba8e054e35f77ef12c8.png)

Mempool

Once a transaction is confirmed on the Ethereum blockchain, it's irreversible.

However, there are ways to replace a transaction by sending another transaction with the same nonce, but only if the initial transaction hasn't been confirmed yet.

The nonce is crucial for transaction processing. It prevents double-spending and ensures transactions from an address are executed in the correct order. Each transaction from an address must have a unique nonce, incrementing sequentially.

What transaction types exist?
-----------------------------

• Regular

• Contract deployment

• Contract execution

**Regular transactions** transfer ETH between accounts. Nothing special here, we all do this through our Metamask when sending funds between accounts.

![Metamask sign](https://storage.googleapis.com/papyrus_images/a0a3fd0f721c02a6350150b8aed231f1e492257d95ae8462a79a18c4319b779e.png)

Metamask sign

**Contract deployment** transaction creates a new contract with a unique address. This type of transaction has a zero address for the recipient (0x0000...0000) and the data field has to contain a contract bytecode.

**Contract execution** transaction interact with deployed contracts. The recipient is the address of the smart contract, and the transaction data field holds encoded information about the function to be executed.

Below is an example of a CloneX transfer:

[https://etherscan.io/tx/0x704887d812d3c5a65ec7de5165d7f506c27a1fca25461699cce89f2189b52c31](https://etherscan.io/tx/0x704887d812d3c5a65ec7de5165d7f506c27a1fca25461699cce89f2189b52c31)

What is gas?
------------

It's important to understand the concept of gas in Ethereum transactions. Gas measures the computational work needed for a transaction or smart contract execution. Each operation within a transaction consumes a specific amount of gas.

The gas cost is determined by multiplying the gas used by the gas price set by the sender. The total gas cost is paid by the sender in ETH, incentivizing validators to execute the transaction.

You can check gas prices on Etherscan at any time:

[https://etherscan.io/gastracker](https://etherscan.io/gastracker)

Validators typically prioritize transactions with higher gas prices, as it increases their potential rewards. This leads to a competitive market for gas prices, which fluctuates based on network demand. Users can adjust their gas price to balance transaction speed and cost.

For faster transaction confirmations, users can set a higher gas price, making their transaction more attractive to validators. But be cautious, setting a gas price too low may result in a long wait time or even no confirmation at all.

Transactions can be sped up or canceled by sending another transaction with the same nonce but a higher gas price. This replaces the initial transaction in the mempool, as validators are more likely to process the transaction with the higher fee.

What are the possible states for a transaction?
-----------------------------------------------

• **Pending** - Awaiting confirmation in the mempool

• **Queued** - Cannot be mined yet due to another pending transaction

• **Successful** - A transaction has been confirmed and processed

• **Cancelled** - Can no longer be mined, replaced by a transaction with a higher gas fee, same nonce, and a null value for the data and/or value field

• **Failed** - A transaction failed due to insufficient gas, incorrect data, or other issues

Common reasons for a **failed transaction** status are:

• Insufficient gas limit

• Insufficient balance in the sender's account

• Invalid transaction data

• Reverted smart contract execution due to internal errors or conditions not met

Transaction throughput
----------------------

Ethereum's transaction throughput is limited by the block gas limit, which is the maximum amount of gas that can be included in a single block. This limit is determined by validators and can be adjusted over time to improve network capacity.

Security
--------

It's important to be aware of security when dealing with Ethereum transactions. Always double-check the recipient's address, ensure your private key is secure, and be cautious of signing random stuff.

Here is my thread about staying safe in web3:

[https://twitter.com/0xMarko/status/1638541332036591618](https://twitter.com/0xMarko/status/1638541332036591618)

Conclusion
----------

Understanding basic concepts like Ethereum transactions is vital for using the network effectively.

Keep exploring and stay informed!

---

*Originally published on [0xMarko](https://paragraph.com/@0xmarko/transactions-101)*
