# Transaction / Event / Chain state

Blockchain networks possess the characteristics of a distributed system. Their design primarily aims to maximize ***Consistency***. Therefore, any change within the state of the blockchain network always follows a specific process: someone initiates a transaction, it goes through ordering and validating, is submitted by validators or collators, and finally, it's packed into a block and gets finalized to ensure that no further changes occur, which reaches ***Finality***.

The term ***Consensus*** refers to a shared understanding or viewpoint by a group of nodes in a blockchain network. These nodes observe, supervise, and share a common "world view" (their version of reality). If any segment of these nodes has a differing world view, in a broader sense, it indicates that they are now part of different blockchain networks because a blockchain forking has occurred. And the common way to determine if the consensus is stable enough, is to check the finality.

Additionally, why a blockchain network keeps producing the empty blocks even there is no transaction? Because "**At the moment, there is no transaction!**" is also a ***Consensus***.

There are 3 kinds of information being used mostly during the integration with a blockchain system:

1. Transaction (a.k.a. Extrinsic in Substrate-based blockchain network)
2. Event
3. Chain state

### Transaction (Extrinsic)

Essentially, a Transaction is a ***Description how to modify the state of blockchain network***.

In usual case, a transaction is signed by the transaction origin (sender), containing the information:

* Target module information (a.k.a. Pallet in Substrate-based blockchain network)
  * For example, `balances` for transferring FT
* Invoking method and arguments
  * For example, `balances.transfer(receiver, value)`
* Nonce
  * Indicating this is ***n-th*** transaction of the sender, starting from `0`)
  * Supporting the transaction queueing
* Transaction Fee
  * Which is paid to the collators or validators

Whether a transaction is successful or failed, once it's finalized, it becomes part of consensus.

### Event

As a best practice, a method in a module should emit some Events to notify the external world what happened inside the transaction.

Sourcing the Events helps building a robust, error-tolerant system, but it is also more complicated than usual software pattern.

It is always helpful to wait for the block finalization, and then source the events again for the accurate business logic or computation outside the blockchain network (a.k.a. off-chain).

### Chain state

A Chain state is usually in a key-value form inside blockchain network storage.

With special trie structure, it is doable to fetch a state with a specific block number, for example, get FT balance of an address at block `100`, and get another one at block `200`, to see the FT balance under two different time context.
