A Byte of Blockchain - Week 44
Transactions in Ethereum

A Byte of Blockchain - Week 44 Transactions in Ethereum

·

6 min read

Recap

Last week we discussed custody in terms of traditional assets & extrapolated that to crypto with additional features & risks specific to crypto assets.

Basically, it all starts with a wallet, the keys & addresses under that wallet which then "connects" to the Ether in the Ethereum Blockchain through signatures.

Keys_Ethereum.jpg

Transactions

Today we will go further & explore transactions on the Ethereum Blockchain. Before getting into Ethereum, let us step back & understand what is a transaction.

A transaction is a completed agreement between a buyer & a seller to exchange goods, services or financial assets in return for money. (Source : here)

So, there is

a. A Buyer

b. A Seller

c. Goods / Services / Financial Services

d. Money paid for goods / services / financial services

Transactions between parties are recorded for legal & accounting purpose.

Recording a Transaction (Traditional services)

The fundamentals of recording a transaction does not change just because the transaction is on a Blockchain. In recording a normal transaction, there is a

a. Transaction ID

b. Transaction Date

c. Initiator ID (ID of initiator of transaction or sender)

d. Beneficiary ID (ID of beneficiary of transaction or receiver) &

e. Transaction Amount

Transaction Components.jpg

There could be additional fields depending on whether the transaction is local or international or within the same bank or with a different bank etc.

Recording a Transaction (Ethereum)

In the context of Ethereum, what is a Transaction?

Transactions are signed messages :

a. originated by an Externally Owned Account

b. Transmitted by the Ethereum network &

c. Recorded on the Ethereum Blockchain

(Source : here)

So, a transaction is normally originated by an Externally Owned Account (meaning someone with a wallet).

A transaction is what causes a change in state of the Ethereum network. We discussed "state" of the Ethereum network in one of my earlier blogs. To recap, what does change of state mean?

The below visualizations make it clear :

Slide1.JPG Slide2.JPG Slide3.JPG

  1. State 1 is when Alice had $1,000 in her account & John had $0.

  2. Then Alice initiates a transaction to transfer $500 to John's account.

  3. State 2 is when Alice balance reduces to $500 & John's balance increases to $500.

This transaction has caused a change in state reflected in the updated balances of Alice & John.

Transaction Field Structure in Ethereum

In addition to the normal fields in a typical transaction data structure, there are additional fields in Ethereum due to it's decentralized nature.

The fields in a transaction data structure in Ethereum are :

  1. Beneficiary Ethereum Address

  2. Value

  3. Data

  4. Nonce

  5. Gas Price

  6. Gas Limit

  7. Digital Signature

Some of the above are straightforward & does not require further explanation. Let us focus on the below today:

  1. Nonce

  2. Gas Price

  3. Gas Limit

Nonce

In the context of Bitcoin, we saw nonce as a "counter" in the Block header which keeps incrementing to solve the proof of work algorithm to arrive the required hash which is less than or equal to the target hash.

In Ethereum, nonce is also a counter in the Originating Ethereum Address which increases as transactions are initiated from that Address. For e.g., the nonce for the first confirmed transaction is 1 & increases by 1 each time a transaction is initiated & confirmed for that address. The objective of nonce here is to be a counter for transactions initiated from a wallet.

Why is a nonce important? For two reasons :

  1. For nodes to be aware which transaction was initiated first in sequence & needs to be approved first.

  2. To ensure transactions are not duplicated since each transaction will have a unique nonce.

A wallet keeps track of nonces for all Addresses managed by that wallet.

Nonce.jpg

Gas Price

We explored "Gas" in Week 40. Let us recap an example :

We use gas to power our vehicles. Imagine a car rental where the car is provided with the gas prefilled. At the end of the day, when you return the vehicle back to the rental agency, you will be charged only for the gas actually used & not for the entire amount of gas filled in when you took the car.

gasoline-g4f6368ec0_1280.jpg

The more distance you travel, the more gas is used. Using this analogy, every utilization of resources (memory / storage space / processing power) consumes gas which in turn increases the cost of processing that transaction. The more resources utilized, the more Gas is paid by the transaction initiator.

In a simple transaction like sending funds from one account to another or simple calculations like adding, multiplication etc, gas cost is less compared to more complex transactions like, which involve checking for conditions before transferring funds etc.

In other words, if there are more conditions in a transaction which makes the transaction complex & hence utilizes more resources to process that transaction, the gas fees will be higher. This mostly applies to smart contract related transactions which can be complex in nature. (We will explore smart contracts in the coming weeks).

Gas Price.jpg

Gas is required to ensure efficient utilization of resources of the Ethereum platform by preventing transactions which wastes resources, never ends or keeps looping forever.

The "GAS PRICE" field in a transaction is used to set the price of ether that the initiator is willing to pay in exchange for gas. Just like in traditional banking where priority customers are charged higher fees but get priority service, higher the gas price, higher the likelihood of the transaction being confirmed faster.

Gas Limit

Gas Limit is the maximum amount of gas the user is willing to pay to ensure his / her transaction is successful in Ethereum. A good analogy is a car where gas is prefilled & that's all the gas that can be used for that trip. The prefilled gas is the maximum amount of fuel needed to reach a destination. The actual utilization could be lower or higher than the limit. If the actual utilization ends up higher than the limit, then you run out of gas.

There are market forces in play during transaction confirmation. Depending on the actual market value of gas, a transaction gets confirmed faster or will be delayed depending on the gas price compared to the market value. If the gas price is higher than the market value, the transactions get confirmed faster & vice versa.

Setting the right gas limit is also important since if it is set too low, your transaction may run out of gas.

We will explore gas in more detail in the coming weeks.

We will explore the below next week :

  1. Digital Signature

  2. Data

  3. Value