How a transaction gets into Cardano's blockchain
When Alice sends 1000 ADA coins to Bob she uses her wallet. Bob will receive the coins in a few seconds. In the article, we will go through the whole process and explain what happens behind the scene in this scenario.
ADA coins belong to their owners
Cardano network is able to separate the ownership of ADA coins and the process that transfers the ownership from the security point of view. It must be ensured that only users can manipulate with their coins and nobody else including the network. Who is the network? Cardano is a peer-to-peer (P2P) network (client-client network). It means that it consists of many independent clients. There is nothing like a server or a centrum. Every transaction is broadcasted into the network and propagated by clients. Clients of pool operators are responsible for the insertion of transactions into a new block. The schedule of pools that will get the right to produce blocks is not known in advance. The network propagates transactions to all pools. A pool that becomes the slot leader can insert all received transactions into a new block. The new block is then broadcasted to the network in a similar way as transactions are broadcasted.
Everyone can install the client and participate in transferring transactions. Everyone can establish a Cardano pool. Many entities get in touch with transactions and it is easy to join this group. There must be a mechanism that prevents entities to modify transactions. Nobody, including pool operators, is able to do so. The reason is that users protect their possession of coins by cryptography. Only the owner of a private key is able to create and sign a transaction for a corresponding address. When a transaction is created then nobody is able to modify it since it is not possible to sign it without the possession of the private key. The private key is not compromised when it is used for signing a transaction. The same private key can be used more times in a row in order to spend coins from the address.
When Alice sends ADA coins to Bob then she signs a transaction. You can imagine the transaction like a message that says that 1000 ADA coins should be put into Bob’s address. The message must be signed by the private key. It is proof that Alice, as the owner of the public address, wishes to send their coins. There is a link between the private key and the public address. A public key is generated based on the private key. The public address is then created based on the public key.
Notice that the transaction would not be valid without the digital signature. If somebody else tried to create a transaction that would spend coins from Alice’s address then the transaction would not be valid without the digital signature. Let’s assume that Alice has well-protected her private keys since she uses a hardware wallet. Thus, nobody else is able to provide a valid signature. The transaction would not be considered valid by all clients in the network. A pool that is the slot leader validates all digital signatures of all transactions that are to be inserted into a new block. Invalid transactions are discarded and will not get into a new block. Even if the pool inserted an invalid transaction into a block then other clients and pools would not insert the block into their versions of the blockchain. The whole block would be discarded by the network.
Pools are able to process transactions but they are not able the modify them. Processing of transactions is a decentralized process that can do only predefined action. The actions are defined in the source code of the Cardano clients (full nodes). Despite the fact that everybody can change the behavior of the client it is not possible to modify transactions. It is not about the source code but about the cryptography. When a new block is created pools not only validate transactions but verify other things. For example, pools verify that Alice has sufficient balance on her account and can spend 1000 ADA coins. It is also necessary to verify that Alice did not try to spend the same coins twice in two transactions. It is also needed to ensure that the number of coins in the circulating supply does not unexpectedly change.
ADA coins exist in the ledger and the Cardano network protects them via the decentralized processing of transactions. ADA holders share the same coins and are allowed to transfer them by signing transactions. The network is always involved in the process of passing ownership of coins to new owners. It is needed to realize that blockchain is basically a collection of transactions. All blocks from the beginning to the end can contain transactions. Every added block changes the current state of the blockchain. Ownership of the coins is directly connected to the possession of corresponding private keys. However, to spend the coins, the network must be involved in order to change the record in the blockchain via transactions.
What happens when the ownership of coins changes?
Let’s start with a seemingly not related example. Imagine that Alice wants to chat with Bob via a network communicator. They can use a P2P communicator so the messages are sent directly from Alice to Bob, and vice versa. There is no middleman between them. Alice writes a text and the text appears in the window of Bob’s communicator. They could also use a client-server communicator. In this case, Alice would send a message to Bob but the message would be sent first to a server. The server would deliver the message to Bob. The result would be the same, Bob would receive the text. The difference is the middleman. The server that can capture the messages and misuse them. For example, the server’s administrator could read all messages and find some secret that Alice wanted to disclose only to Bob. Definitely not also to the administrator.
Now, what do you think? Is a blockchain transaction a type of rather peer-to-peer or client-server communication?
We have said that Cardano is a peer-to-peer network. You probably know that a server is a centralized entity and something like that should not exist in the world of a public decentralized blockchain project. Let’s dig deeper before we will answer the question. When Alice sends the coins to Bob then the coins are not delivered directly to Bob’s computer. It is not the same as the text message. The Cardano transaction is not sent to Bob but it is broadcasted to the whole network. Bob’s computer may be switched off and Bob may sleep. Still, he will become a new owner of the coins. The point is that it is the network that will process the transaction and change the record in the ledger. When Alice’s transaction is added into a new block it basically means that 1000 ADA coins are taken out from Alice’s address and added to Bob’s address. It is just a proposal at the moment when a pool creates a new block and has inserted Alice’s transaction into it. Once the block is broadcasted to the network and accepted by other clients, the ownership of coins is irreversibly changed.
When Bob wants to check whether Alice sent him 1000 ADA coins as she promised then he has a few possibilities for how to do that. Bob can use the Daedalus wallet. It is a full node wallet and it is necessary to download newly added blocks. Bob switches on his computer and runs the wallet. Once the newly added blocks are downloaded Bob will see that the balance has changed and he can see Alice’s transaction. Alternatively, Bob can use the Yoroi wallet. It is a light-weight wallet that connects to Emurgo’s computer and provides information about Bob’s balance. Bob can see the same result. The coins are at Bob’s address so only Bob can sign a new transaction and spend coins. Every full node in the network has the same record and knows that 1000 coins are at the address that is possessed by Bob. The network does not know that the address belongs to Bob. The Cardano blockchain operates only with addresses and it does not operate with identities.
Let’s now try to answer the question. Alice has broadcasted the transaction to the whole network. Not to a particular server. A randomly selected pool took the transaction and added it into a new block. So, it is not the client-server type of communication. It must be peer-to-peer communication, right? Yes. A typical attribute of P2P networks is that it shares distributed resources. Every node maintains its own version of the blockchain.
Cardano uses PoS network consensus that takes care of time synchronization and random selection of slot leaders. Thanks to the network consensus, a new block is added regularly approximately every 20 seconds by a randomly selected pool. Thus, signed transactions are broadcasted and regularly processed by the decentralized network.
When you own ADA coins then nobody can take them from you. Cardano is a P2P network so it is maintained by many independent entities. There is a decentralized process that cannot be changed at the will of one or a few entities. It is the power of a blockchain network. You can own ADA coins and nobody is able to externally change the rules of Cardano’s network consensus. Only users of ADA coins will be able to do so via voting. Only ADA holders have the decision power to initiate the change of rules and will probably do it in a way that they will not put their wealth into danger. Cardano is a multi-asset ledger so not only ADA but also other assets can be stored in it. Cardano is a very secure ledger due to the high level of decentralization.