Blockchain Academy
We'll get together for networking with people interested in Blockchain including developers and anyone curious about Blockchain.

State

It means a structure in which the "Accounts" of Ethereum are gathered. Simply put, it's all account information on the block chain. These States will change each time a transaction occurs.

In the figure above, you can see that the balances of the Ether that each account has changed since the transaction occurred in the 'State' on the left have changed like 'State' on the right side. If the State' transition function is used in the initial ‘State’, the 'State' is changed as follows. The state transition function (Apply (S) = S ') goes through the following process.


  1. Verify that the transaction is in the correct format, is a valid signature, and matches the Nonce of the sender account.
  2. Calculate the commission with STARTGAS x GASPRICE, and verify the sender's address with a signature. Subtracts the commission from the sender's balance and increases the nonce by 1.
  3. Initialize with GAS = STARTGAS and subtract the GAS value per byte as used in the transaction.
  4. Send the transaction value from the sender's account to the recipient's account. If the destination account does not exist, it will be newly created. If the recipient is a contract, the code in the contract will be executed until the GAS is exhausted.
  5. If the transaction is successful, the consumed GAS is returned to a miner, and the remaining GAS is returned to the sender. If the sender fails to send the transaction due to insufficient funds, or if the GAS is insufficient, everything will be undone. Fees paid only will not be returned.

In ethereum, a state in which nothing happens after a block is created is called a Genesis State. After that, the state changes every time a transaction is executed. Finally, the block contains the most recent Final State, which is shared by all users.