Separation of reading/entry files from the ETHEREUM intelligent contract
Because the popularity of decentralized Ethereum (DAPP) applications is still growing, it is becoming increasingly important to understand how they store data in the chain. In this article, we will examine the methods of extracting reading and registration files from an intelligent contract written in Fort.
Understanding the status of Ethereum
In the intelligent Ethereum Treaty, the state is represented as an object that stores data. Each object can have more functions (variable status), which are access to the recording of points or registration in brackets. For example::
`Solidity
Pragma solidity ^0.8.0;
Mycontract {
Uint meter counter; // variable only to read
Mapping (address => uint) public note; // User address map to counterattacks
Incrementcounter () public fee function {
Counter += 1;
}
Upatatemo functions (_user address, uint amount) public {
Note [_user] = sum;
}
}
In this example, the variable Count 'is a reading function -this can be accessed to Dot (
Mycontract.cunter). "Memo" is also a reading function that can be accessed through registration (
Mycontract.Memo [” User “]).
separation of variables reading and writing records
You need to apply the following approaches to extracting reading and recording of state variable sets from the intelligent Ethereum Contract:
1.
- Use a reflection : You can use the functionality of reflection of reliability (SOLC -Reflection
) to check and adjust the variables of the contract.
Example: Settlement of reading and writing files of status variables
Assuming that we have an intelligent Ethereum agreement called "Mycontract" with a variable only to read the "meter" and the "notes" set, we can use the following steps:
1
Bash
$ Solhint Get-Variables Mycontract
Pult: uint
Note: mapping (address => uint)
2
`Bash
$ SOLC-REFLEX-PRINT-VARS MyCONTRACT
Variable only to read
Pult (uint)
Set Save
Note: mapping (address => uint)
It should be noted that the “-print-vars” symptom is used to print all variables in the contract, including reading and writing and internal variables.
Application
The separation of reading and writing variables from the Ethereum intelligent contract requires a combination of the characteristics of reflection of reliability, “Solhint” and probably manual control using Solscan or other tools. Understanding how to use these techniques, you will be able to better analyze and understand the behavior of your own intelligent Ethereum contracts.
Recommendations
- Use ‘Solhint Get-Variaibles’ to obtain a list of all functions (variable status) in the contract.
- Use the functionality of reliability reflection (‘Solc-Reflection`) with signs of i-druka-vars’ to check and adjust the variables of the contract status to start.
- Consider the use of Solscan or other tools to identify and separate information about your intelligent contracts.