It is the state of Ethereum:
Marki Ethereum: Simple primer
Work with Ethereum, you often track you with the concentration of disobedience. CARTYING – This data structure, which allows you to contain values, linked to the conquest keys (also the values in the form of “klavyshi” or “index”) in the massive structure or the second structure. In this state, we disperse, how to make and use the simple ascent in the object.
What is such a cartilation?
In Ethereum carding – this, at the moment, it is possible to hide the massive meaning, which is indexed by their fields in the massif. A pair of Klavish values is chronic in a single field (the key “key”), behind which the indices of the second field (“index”) follow. This allows you to use effective views and data views.
Correction of the simple field
Here is a simple conservation of the training with two elements:
`'
Contract mymapping {
Uint8 [2] Public MyMAP;
}
'
In this one, we have a contract called "Mymapping", which has the enormous 2 elements (uint8) called" mymap ".
Put carty
To support data deobbering, you can use the functions that make the key and the quality of the quality of the arguments. Sub't consult two functions:
'
Contract mymapping {
Function set (index uint8, uint8 value) public {
Mymap [Index] = value;
}
Get (Uint8 index) function View Retur (Uint8) {
Return MyMAP [Index];
}
}
'
In the function of "set", we mask the imposed indication. In the function of "GET", we are simply uninstalled, linked to data.
uspolzing athod
Now when we have made and broken our cartilation, let's use it for the chronicles of certain data:
'
Contract mymapping {
Mymapping Mymap;
Builder () Public {
Mymap.set (0, 1); // Install the first element on the index 0
Mymap.set (1, 2); // Install the second element of the index 1
}
Getmyitem function (index Uint8) Social representation of Vozurat (Uint8) {
Return mymap.get (index);
}
}
'
In this one, we carry out the "MyMapping" contract and install two elements in the system, using theSetfunction. We use the "Get" function to extend the element outside the course.
Prime Upolizing
To verify our system, name the "Getmyitem" function:
'
Pragma Polidy ^ 0.8,0;
Mycontract {
Mymapping Mymap;
Builder () Public {
Mymap.set (1, 5); // Install the element in the index C 1 by 5
}
Getmyitem function (index Uint8) Social representation of Vozurat (Uint8) {
Return mymap.get (index);
}
}
'
In this beginning, we call the function ofGetmyitem with our own counter -attaque. Postkolka in index 0 in index 0 no element, the function is simply on 0.
conclusion
Ethereum receives an effort in the form of a mesh and a data existence. In this state, we studied how to create a simple system in the global object with the use of water. We closed the detachment and he used it for the cartilage and the effort of the elements. This primer derôt derôt the universal of Ethereum and their potential implementation in the Smart-End.
I hope this helps you fall in the middle! Let me know, if you have a digital question or if you have to be added.