There are 2 types of Nonce in Ethereum:
Account nonce – It’s simply the transaction count of an account. Each address has a nonce. Addresses can have the same nonce
Proof of work nonce – The random value in a block that was used get the proof of work satisfied (depending on the difficulty at the time). This is
a meaningless value in a block which can be adjusted in order to try to satisfy the proof of work condition. It is result of math quizzes in proof of work processing.
What are benefit of Nonce in Ethereum?
1. Avoid double spending
Ethereum is a decentralised network of nodes. When you send a transaction to the ethereum blockchain, it will be sent into the mempool, then it will be mined by miner and it will be included in a valid block. Transaction with nonce number it mean transaction in serialization.
For example, you want to transfer 1ETH from address A to address B. This transaction will be sent to mempool with nonce is 0. Then this transaction will be brocasted to network. If address A want to transfer 2 ETH to address B, second transaction have to wait miner valid first transaction. Because second transaction with nonce is 1. Therefore, Nonce number helps system avoid double spending
2. Prevention of Replay Attacks
Replay Attacks it means when you do a transaction and it will be mined, this data is visible on blockchain to anyone. So, anyone can copy and paste this transaction data and send to the network.
Each transaction data output is unique even if all other variable remains same. When nonce include the transaction, if someone tries to carry out ‘replay’ attack, miners reject that transaction as ‘duplicate’ transaction. Because system will recognize that this nonce has been used before for previous transaction). Hence, this way, nonce helps prevent such replay attacks.
Blockchain Ethereum – Ví dụ về hàm Delegatecall trong solidity
Blockchain Ethereum (P4) – Kết Nối Các Node Sử Dụng Bootnode
Blockchain Ethereum (P3) – Cài Đặt Private Blockchain trên nền tảng Ethereum
Install web3 and nodejs
Sử dụng Virtual Box
Đọc sách 2021