What is the Solidity programming language?(part1)
Solidity is a brand-new programming language created for Ethereum smart contracts. Solidity programming language Ethereum, the second largest cryptocurrency market by capital size, was launched in 2015 under the leadership of Christian Ritweissner. In the next section, we will introduce some of the features of Solidity before taking a deeper dive into it.
Solidity, voting, cryptocurrency auctions, financial market activities, multi- signature wallets, etc. It can be used to create contracts such as:
To begin with, we need to examine each stiffness property more deeply; We said that Solidity helps Ethereum smart contracts; So what mechanisms do smart contracts have? So the first step to knowing robustness is knowing smart contracts.
What is a smart contract?
If you are unfamiliar with this finance concept, you should learn this first. If we want to briefly explain the smart contract; A smart contract is a self-executing contract in which the terms of the agreement between buyer and seller are written directly in lines of code. Let’s say you went to buy a house, you have a contract in front of you, the rules of which are implemented in words on paper; In the virtual contract, everything works in codes. It controls code execution and transactions are traceable, but it should be noted that transactions are irreversible.
Smart contracts are high-level application codes compiled into EVM bytecode and deployed to the Ethereum blockchain for further execution. Contracts allow us to make valid transactions without the involvement of any third party, as we say these transactions are traceable and irreversible.
What are cryptocurrencies?
Cryptocurrency is a digital or virtual currency that is secured by cryptography, making it nearly impossible to cheat or physically spend it in the real world. Many digital currencies are decentralized networks based on blockchain technology.
One of the defining characteristics of all digital currencies is that they are generally not issued by any central authority and are theoretically immune to government intervention or manipulation. These virtual currencies have different values and sometimes they can be very helpful to different businesses. It is predicted that physical money will disappear in the future and banknotes will be replaced by cryptocurrencies.
What is Blockchain?
Blockchain is a database shared between nodes or nodes of a computer network. As a database, a blockchain stores information electronically in digital form. Blockchains are known for their vital role in digital currency systems such as Bitcoin in keeping a secure and decentralized record of transactions. The innovation of blockchain is that it guarantees the accuracy and security of data recording and creates a safe and reliable environment without the need for a third party.
One of the most important differences between a regular database and blockchain is how the data is structured. A blockchain collects information into groups called blocks; that is, each block stores a set of information. Blocks have certain storage capacities, and the volume of each block may differ from another block. As each block is filled, it is closed and linked to the previous filled block, creating a chain of data known as the blockchain. All new information following the newly added block is compiled into a newly created block, which, once filled, is also added to the long chain before it.
While a database usually structures its data into tables, a blockchain, as the name suggests, structures its data into interconnected pieces (blocks). When implemented in a decentralized structure, this data structure creates an inherently irreversible data timeline. When a block is filled, it is placed in the row of filled blocks before it and becomes part of the timeline. Each block in each chain has a unique time ID when added to the chain.
What is Ethereum and what does it have to do with Solidity?
By definition, Ethereum is a decentralized global software platform that supports blockchain technology. It is mostly known by its native digital currency Ether or ETH, which is what its name is based on.
Anyone can use Ethereum to build any digital security technology. This token is designed to be used on the blockchain network but can also be used by participants as a way to pay for work done on the blockchain.
Ethereum is designed to be scalable, programmable, secure and decentralized. Blockchain is the choice of developers and companies developing technologies that will change how many industries operate and how we live our daily lives.
By default, Ethereum supports smart contracts and basic tools for decentralized applications. Most decentralized finance (DeFi) and other applications use smart contracts along with blockchain technology.
Now that you have sufficient knowledge about cryptocurrencies, blockchain, ether tokens, smart contracts and ethereum, we can introduce Solidity.
What is the use of Ethereum?
Ethereum is a decentralized, open-source platform based on blockchain space used to run smart contracts, that is, programs that execute the program exactly as planned, without the possibility of fraud, third-party intervention, censorship, or failure. The platform offers approximately 260,000 different digital currencies. Ether is a digital currency produced by Ethereum miners and used to reward calculations made to secure the blockchain.
Ethereum Virtual Machine (EVM)
Ethereum Virtual Machine (EVM) is a runtime for executing smart contracts on Ethereum. This concept broadly focuses on securing and executing untrusted code using an international network of public nodes. EVM is specialized to prevent Denial of Service attack and verifies that applications do not have access to each other’s state, also ensuring that communication is established without possible interference.
Now it’s time to get to know Solidity!
Now that you know about cryptocurrencies, blockchain, ether tokens, smart contracts, and ethereum, we can start examining robustness; Note that robustness is a relatively difficult, high-level language; so if you don’t understand some of its concepts and don’t know this article might be a bit difficult for you since you don’t have a background.
How can we learn resilience?
There are several ways to install the Solidity compiler; Select your preferred option and follow the steps listed on the installation page.
Example: In the example below, we have discussed a solid application example that shows how to write a smart contract in Solidity.
pragma version
The Pragma version is a version of the Solidity compiler. Pragmas are instructions to the compiler on how to deal with code. All robustness source code must begin with “pragma version”, which is an important indicator of robustness compiler version. The versioning pragma helps us make code incompatible with later versions of the compiler that may make changes. The Pragma version contains, for example, code indicating that the code is compatible with version compilers greater than and equal to 0.4.16 but less than 0.7.0.
contract keyword
The keyword contract declares a contract defined and isolated within the framework of codes.
State variables or declaration variables:
State variables are stored persistently in smart contracts, these variables and their storage are available on the Ethereum blockchain. The row uint public var1 is a state variable of type uint called var1 which does not contain the integer (the sign means the same as the positive 256 bits).
Function declaration
Set function (SET) is a function that takes an x variable and a y variable of data type uint as parameters. What you saw was a simple smart contract example that updates the value of var1 and var2. Anyone can call the function set and overwrite the var1 and var2 values stored on the Ethereum blockchain. This is an example of a decentralized application that is censored and does not affect the shutdown of central servers. This smart contract will exist as long as someone runs a node on the Ethereum blockchain.
In this contract, the sum of the variables is calculated by adding the values of var1 and var2 variables and the get function takes the total value of the state variable and prints it.
Smart contract in Solidity
Smart contracts enable trusted transactions and agreements between heterogeneous and anonymous parties without the need for a central authority, legal system or external enforcement mechanism. Although blockchain technology was primarily designed as the basis for Bitcoin, it has gone far beyond the basics of virtual currency and is a centralized method for moving cryptocurrency or any other transaction. Now you understand the concept of smart contract, but there are small points within the concept that need a separate explanation; For example, blockchain, Ethereum, cryptocurrency, etc.