Ethereum Transactions:
Anything that you want to do inside a blockchain has to be via a transaction.
A transaction contains the below attributes:
- To: The recipient (account or contract address).
- From: The sender (account or contract address), who is initiating the transaction.
- Gas Price: Each OpCode (any computation step we want to execute has the equivalent OpCode) in the EVM has a fixed price. Gas is an execution fee that senders of transactions need to pay for every operation made on the Ethereum Blockchain. Since it’s a kind of ‘crypto-fuel’ it has been given the name 'gas.'
- Gas Limit: The maximum computational steps the transaction can execute; it means every transaction has a maximum number of allowed computational steps.
- Gas Used: Sum of all the gas for all the OpCodes executed.
- Value: The amount of Ether in Wei to be transferred (the base unit of Ether is called Wei).
- Signature: To identify the sender, so that sender's intention can be verified.
- Nonce: The transaction sequence number for the sending account; which helps to index and process transactions in the right order.
- Block Height: This is the unique block number.
- Data: The payload; raw data or a contract.
If you specify too little gas then the transaction will start to be executed but may run out of gas and be stopped with an 'Out of Gas' exception.
Note: Ethereum is not based on RSA encryption. Instead, it uses Elliptic Curve Cryptography (ECC).
What Is OpCode?
This is a machine language instruction which instructs the machine to perform specific operations. Thus, OpCode could be understood as an assembly level language.
Whatever code we are writing as part of smart contracts or transactions, it gets compiled and interpreted by the EVM (Ethereum Virtual Machine) and generates equivalent OpCode so that the EVM can execute it when required.
Each of these operations has some cost, measured in units of 'gas.' The cumulative summation of all OpCode in any transaction is the total cost for that transaction.
Some Ethereum OpCode and its Significance Is Shown Below:
Stop and Arithmetic Operations:
Comparison & Bitwise Logic Operations:
SHA3:
Environmental Info:
Block Info:
Stack, Memory, Storage, and Flow Operations:
System Operations:
We don't need to write a program in low-level (using OpCode) as high-level languages exist for designing the smart contracts.
Understanding Transaction Cost
- Estimated Transaction Cost
If the GasLimit= 2100 and GasPrice= 23.089 gWei
Interpretation of above line - "we wanted to spend a maximum 2100 Gas at the price of 23.089 gWei"
So, the estimated maximum transaction cost = GasLimit * GasPrice
= 2100 * 23.089
= 53104.7 gWei
= 0.0000531047 ether (1 ether = 1000000000 gWei)
- Actual Transaction Cost
If the GasUsed = 2040 and GasPrice=23.089 gWei
Interpretation of the above line - "we spent 2040 Gas at the price of 23.089 gWei."
So, Actual transaction cost = GasUsed * GasPrice
= 2040 * 23.089
= 47101.56 gWei
=0.00004710156 ether (1 ether = 1000000000 gWei)
I hope this will give you a better understanding about blockchain and Ethereum transactions.
Happy learning!
No comments:
Post a Comment