A Beginner's Guide
Hardik Makwana
Software developer | Web App Developer | Automation specialist | Python | Problem Solver
About Solidity :
Solidity is an object-oriented, high-level statically typed programming language used to create smart contracts that automate transactions on the blockchain. After being proposed in 2014, the language was developed by contributors to the Ethereum project. The language is primarily used to create smart contracts on the Ethereum blockchain and create smart contracts on other blockchains.
?????????Solidity is similar to one of the most common programming languages, JavaScript. It can be considered as a dialect of JavaScript. This means that if you understand JavaScript, it can be easy to pick up Solidity. Solidity also shares similar characteristics to the programming languages C++ and Python.
?
How it works :
The beauty of the Ethereum ecosystem is that so many different cryptocurrencies and decentralized applications can use it. Smart contracts make it possible for unique technologies to be made on Ethereum for all kinds of businesses and organisations.
?????????Smart contracts build using Solidity can be thought of as a way to automate business and non-business processes between people. This ensures that people making transactions on the blockchain do not have to worry about risks such as fraud or not being able to use the same currency.
?????????One of the key components that makes the execution of the Solidity code possible is the EVM(Ethereum virtual machine). The EVM is described as a virtual computer on the blockchain which turns people’s ideas into code that runs applications on the blockchain.
?????????Solidity creates machine-level code that is executed on the EVM. A compiler is used to break down high-level human-readable code, which it turns into instructions that the processor reads. Different platforms provides free Solidity compilation, including the remix online compiler and a downloaded command-like compiler on a PC.
Use of ?Solidity :
?????????With Solidity you can create contracts for uses such as Voting, Crowdfunding, blind auctions and multi-signature wallets.
Gas :
????????Any transaction?that modifies the blockchain costs gas. The user that generated the transaction pays for the gas.
Solidity provides two types of variables – State and local variables.
State variable :
Initialization of state variable
Local variable :
Initialization of local variable
?
领英推荐
Functions :
??????????????????A function is a block of code or a collection of statements compartmentalized together to perform a task. It takes an input, does some processing and produces an output. These are the types of functions in a solidity:
Private : The function can be accessed only from inside the contract.
Public : The function can be accessed from everywhere.
Internal : The function can be accessed from inside the contract as well as the child contracts that inherit it.
External : The function can be accessed from outside the contract. other functions of the contract cannot invoke it.
Pure : A pure function does not read or modify the variables of the state.
View : A view function only reads but doesn’t modify?the variables of the state.
Constructor :
??????????????????A constructor in solidity is a special function that is used to initialize state variables in a contract. The constructor is called when an contract is first created and can be used to set initial values.
????How to create constructor
Storage vs Memory :
Storage
Memory
Mapping :
??????????????????Mapping is identical to a dictionary in every other language. In solidity, it’s a hash table that stores data as key-value pairs, with the key being any of the built-in data types but not reference types and the value being any type.
??????????????????When it comes to solidity and the Ethereum blockchain, mappings are most commonly used to link a unique Ethereum address to a corresponding value type.
Example : A structure is defined and a mapping is made in the contract mapping example.
So that’s about the introduction of Solidity, how it works and important terminologies. In the next part, we will deploy our first Smart Contract with complete guidelines.
Department of Animation, Gujarat University at Gujarat University Department of Animation & IT IMS
2 年WOW !! Superb