Programming blockchain part 5: Solidity programming language
- Programming blockchain part 1: C ++ programming language
- Programming blockchain part 2: Javascript programming language
- Programming blockchain part 3: Python programming language
- Blockchain programming part 4: Java programming language
The final part of the blockchain programming series will refer to Solidity. For anyone who wants to learn how to create DAPPs (hierarchical applications) or access ICO games, learning about Solidity is a must. The following article will give you a basic overview.
Solidity programming language
Solidity was developed by Gavin Wood, Christian Reitwiessner, Alex Beregszaszi, Yoichi Hirai and a number of other members of Ethereum allow to write smart contracts on the blockchain platform like Ethereum.
Solidity is a neatly designed language with a syntax very similar to ECMAScript (Javascript). There are some key points to keep in mind in Ethereum Design Rationale, namely that we will work in a stack-and-memory model with the size of 32-byte instructions. EVM (Ethereum virtual machine) allows access to the ' stack ' program like the registration space where the memory addresses are attached to create the Program Counter loop (to control the sequence program), temporary "memory" expandable and "storage" permanently written to blockchain, and most importantly, EVM requires a total of determinism in smart contracts.
So before continuing, see the example of Solidity's basic contract. (Code is taken from github).
Run a simple loop in Solidity:
contract BasicIterator
{
address creator; // reserve one "address" -type spot
uint8 [10] integers; // reserves a chunk của lưu trữ cho 8-bit 10 không xác định Integers trong một mảng
BasicIterator function ()
{
creator = msg.sender;
uint8 x = 0;
// Section 1: Assigning values
while (xintegers [x] = x;
x ++;
}}
function getSum () constant returns (uint) {
uint8 sum = 0;
uint8 x = 0;
// Section 2: Adding the integers in an array.
while (xsum = sum + integers [x];
x ++;
}
return sum;
}
// Section 3: Killing the contract
function kill ()
{
if (msg.sender == creator)
{
suicide (creator);
}
}
}
Now let's analyze!
Part 1: Specify value
In the first step, fill in an array called " integers " which contains 10 8-bit unsigned integers. This will be done through a while loop. Let's see what's happening inside the while loop.
while (xintegers [x] = x;
x ++;
}
Remember, we have assigned the value ' 0 ' to the integer x. The while loop goes from 0 to integers.length . Integers.length is a function that returns the maximum capacity of the array. So if you decide that an array will have 10 integers, the arrayname.length will return a value of 10. In the above loop, the value of x goes from 0-9 (<10) and also assigns the value of itself. it gives integer arrays. So at the end of the loop, integers will have the following values:
0,1,2,3,4,5,6,7,8,9.
Part 2: Add array content
Inside the getSum () function, the content of the array itself will be added. That will be done by repeating the same while loop above and using the "sum" variable to add content to the array.
Part 3: Finish the contract
This function ends the contract and sends the remaining amount in the contract to the contract creator.
When asked about the inspiration and motivation behind creating Solidity, Dr. Gavin Woods said:
'It [Solidity] is a sophisticated tool to develop contracts that can ultimately provide both developers and users with information about what the code has done. To help with this, I created NatSpec, a contract-friendly document format, and made it the best option in Solidity. I have also proposed a set of official validation languages (not yet implemented) to maximize the types of tools that ensure accuracy can be implemented.
I introduce things as a best option for Solidity languages to provide an abstract concept for LOGs, similar in form to function calls. The inspiration for that comes from the 'signal' of the Qt meta-object system.
A later feature that Christian R. and I found together was the function of modifying functions; Allow properties to be set as part of the function signature to make some modifications to the content of that function. This language is very suitable for contract-oriented programming ".
This article covered 5 languages used for blockchain programming. In fact, there are many other languages that you can use with the blockchain. If you are a programmer, the development potential is really endless. As the world is increasingly decentralized and blockchain is becoming a more mainstream component, the future for blockchain programming is definitely limitless.
See more:
- Here are the 3 most readable blockchain books
- This is why 10 years from now, every company will use blockchain
- What is Ethereum, Smart Contract technology and ICO technology?
You should read it
- Programming blockchain part 2: Javascript programming language
- Programming blockchain part 3: Python programming language
- Top 5 languages for blockchain programming
- What is a blockchain? How does blockchain work? Pros and cons of blockchain?
- [Infographic] The effects of Blockchain on E-commerce and Security
- Great recruitment needs, a blockchain engineer can get the salary level equal to the AI developer
- Here are the 3 most readable blockchain books
- This is why 10 years from now, every company will use blockchain
May be interested
- eQuiz - VB.NET testing test - Part 1we will continue with the vb.net programming language test, in total there will be 15 questions with no time for answering each sentence. there will be some questions with many different answer options.
- Why should you learn Python programming language?python is a multi-purpose programming language created in the late 1980s and named after monty python drama group. let's tipsmake.com find out 3 reasons you should learn python programming language in this article!
- The reason why C programming language is never outdatedieee spectrum magazine ranked c as the leading language in 2017 before both java, c # and javascript. if you study c this year, it won't waste your time and effort. here are five reasons why.
- JAVA test on P3java is a high-level programming language, if you are interested in learning about this programming language, the following test of network administrator will give you lots of useful information.
- Test on C programming P6are you a fan of c programming language and want to learn about this programming language? the quiz below the network administrator has edited and sent you questions about this topic, invite you to experience.
- eQuiz - VB.NET testing test - Part 2in the previous article, i showed you the first part of the vb.net test. and this time, we will continue with part 2 of this popular quiz series on programming languages, the whole test will have 15 questions with unlimited response time.
- What is the first programming language in the world?of course, compared to human language, the programming language's life is much younger.
- What do you know about Smalltalk programming language?smalltalk is the first, dynamically and reflexively object-oriented programming language developed at xerox palo alto research center (parc) in early 1970. the quiz below is with network administrator. let's learn more about this programming language.
- 10 programming languages booming todayhere is a list of 10 programming languages with the fastest explosive speed on github, please refer.
- What do you know about programming language C # P1c # programming language is developed based on c and c ++ programming languages. in the article below, network administrator will go with you to learn about c # programming language through multiple choice questions. let's start.