A complete guide to Solidity and its basics - Part 0

A complete guide to Solidity and its basics - Part 0

Solidity is one of the popular programming languages in the Web3 and Blockchain space that are used for writing smart contracts.?

Solidity is an object-oriented, high-level programming language for creating smart contracts on the blockchain that automate transactions. The language was created by participants to the Ethereum project when it was proposed in 2014.

This language is mostly used to make smart contracts on the Ethereum blockchain. According to its documentation, "Solidity is a curly-bracket language. It is influenced by C++, Python, and JavaScript, and is designed to target the Ethereum Virtual Machine (EVM)."

Solidity is also considered a dialect of JavaScript. This implies that if you know JavaScript, learning Solidity should be simple. Before learning more about solidity let's understand some basic terms of blockchain.

Ethereum Virtual Machine

The Ethereum Virtual Machine (EVM) is the Ethereum smart contract runtime environment. The Ethereum Virtual Machine is focused on providing security and allowing machines all around the world to execute programs.

Virtual machines effectively create a layer of abstraction between the code and the machine that executes it. It is required to promote software portability and to ensure that programs are isolated from one another and from their host.

Smart Contract

A smart contract is a decentralized program that responds to events by executing business logic. Smart contracts are often written in Solidity.

The exchange of money, delivery of services, unlocking of information controlled by digital rights management, and other forms of data manipulation, such as altering the name on a property title, are all possible outcomes of smart contract execution.

Now that you have an idea about EVM and Smart Contract, we can continue learning about the Solidity

?? You can?use an online editor called Remix IDE to Compile and Run your Solidity code

Reserved Keywords

Following are the reserved keywords in Solidity:

No alt text provided for this image

Importing other files in Solidity

Importing a file in Solidity is similar to JavaScript, to import a file you can simply write

import "file";        

Comments in Solidity

Just like other programming languages, Solidity support both single-line and multi-line comments.

- Start the line with // to include a single-line comment.

- Start with /* and end with */ to include a multi-line comment.


// This is a single-line comment

/* 
  But this is a multi-line comment in Solidity
  It is easy, right?
*/        

Variables in Solidity

There are mainly two types of variables available in Solidity.

Local Variables: Variables with values that will persist till the function is completed

State Variables: Variables whose values are kept in a contract storage system permanently

State variable

State variables store the value permanently in the contract storage. Each method should have its own scope, and state variables should be declared outside of any defined functions.

Local Variable

A local variable's context is contained within the function, and it cannot be retrieved from outside of it. These variables are typically used to store temporary values.

Operators in Solidity

Operators are important in every programming language because they establish the groundwork for the programming. Similarly, the functionality of Solidity is also incomplete without the use of operators.

Solidity supports the following types of operators:

- Arithmetic Operators

- Relational Operators

- Logical Operators

- Bitwise Operators

- Assignment operators

- Conditional Operators

Two examples:

Arithmetic Operators

These operators are used to perform mathematical operations.

No alt text provided for this image

Relational Operators

These operators are used to compare two values

No alt text provided for this image

要查看或添加评论,请登录

Cesar Gatica的更多文章

  • Do you know what Computer Vision is?

    Do you know what Computer Vision is?

    Is the field of computer science that focuses in identify and understand objects and people in images and videos. If AI…

  • Types of accounts on Ethereum

    Types of accounts on Ethereum

    If you’ve used Ethereum, you know what an Ethereum account is. Your account address looks something like this:…

  • Crypto Market 2024 events.

    Crypto Market 2024 events.

    VanEck predicts 15 events that will happen in the #crypto market in 2024: 1. The US will experience an economic…

    1 条评论
  • 5 Phases of The Bitcoin Halving

    5 Phases of The Bitcoin Halving

    1. Pre-Halving period Approximately 5.

  • 1$ DOLLAR GUIDE TO SOLANA

    1$ DOLLAR GUIDE TO SOLANA

    Now we will venture into the Solana ecosystem, with just ONE dollar of capital. Showing YOU the user experience.

  • Polygon #zkEVM

    Polygon #zkEVM

    Since Polygon Labs is set to launch its #zkEVM (Zero Knowledge Ethereum Virtual Machine) mainnet very soon, I thought I…

  • A Really brief explanation on Fibonacci Retracements

    A Really brief explanation on Fibonacci Retracements

    Fibonacci retracements are a popular technical analysis tool used by traders to identify potential levels of support…

  • The most innovative projects coming to Arbitrum

    The most innovative projects coming to Arbitrum

    (huge opportunities you can't miss out on) Note: If you do not know what Arbitrum or layer 2 is please refer to this…

  • AI Types and tools you need to know.

    AI Types and tools you need to know.

    I find the advances in Artificial Intelligence (AI) impressive. There are already many more applications than you can…

  • GPT-3, AI and the future is awesome

    GPT-3, AI and the future is awesome

    The world of artificial intelligence has been rapidly evolving, and one of the most noteworthy advancements is GPT-3…

社区洞察

其他会员也浏览了