Solidity

Solidity Blockchain Basics

Solidity Blockchain Basics Main Tips

  • Solidity is used specifically for smart contracts, making it closely related to the blockchain.
  • Understanding the basics of blockchain is essential for learning to work with smart contracts.
  • In this tutorial, we will go over the basics of how blockchain works – just enough to get started.

Solidity Blockchain Basics

A blockchain is a global transactional, shared database.

What this means is that it is enough to participate in the network to access it.

To do this, you must create transactions, which has to be approved by others participating in the network.


Solidity Blockchain Basics Transactions

The term transaction, in the context of blockchain, implies that the change you want to apply (for example – modifying two values) is not there yet, or is fully applied.

Additionally, while a transaction is applied to a database, it cannot be changed by other transactions.

For example:

Imagine you have a table, listing the balances of all accounts containing a particular electronic currency.

When a transaction between two accounts is requested, according to the transactional nature of the database, when some amount of currency is subtracted from one account, it is added to another.

In the scenario, that the transaction is not possible from either side, for example, it cannot be added to the balance of one of the accounts, the transaction will not be applied, so neither of the accounts taking part in the transaction will be affected.

Transactions are also always signed cryptographically by the creator of the transaction.

Using a simple check, this ensures that only the person with the keys to the account can create transactions from it.


Solidity Blockchain Basics Blocks

To explain how blocks work in blockchain, we will first look into the concept of “double-spend attack”, found in Bitcoin transactions.

A “double-spend attack” happens when there are two transactions on the network, both aiming to empty a particular account.

What happens in this scenario?

Simply put, the transaction order is selected for you automatically, and the transactions are bundled into blocks.

Then they are executed and distributed between the participating nodes.

In the case of two transactions contradicting, what happens is simply that the one that comes second is rejected, so it is not executed and does not end up in the block.

The blocks we mentioned here form a linear sequence in time – which is why they are called a blockchain.

In the case of Ethereum, the blockchain is updated with new blocks fairly regularly, that is, about every 17 seconds.

Reverting Blocks

As a part of the “order selection mechanism”, also referred to as mining, blocks are sometimes reverted at the “tip” of the chain, that being the latest blocks.

For this reason, you should keep in mind, that your transactions may be in the blocks that have been reverted and removed, but as time goes by, the less likely that is to happen on the same blockchain.

Read previous post:
SQL SELECT Statement

SQL SELECT Statement Main Tips Using the SELECT statement, you can select specific data from your SQL database. The data...

Close