November 2018
Intermediate to advanced
528 pages
13h 21m
English
As was the case for reading contract storage, you cannot modify states of another contract without defining a setter function.
Let’s have a look at the following example:
contract ContractA { uint256 public state; function setstate(uint _value) { state = _value; }}contract ContractB{ ContractA public OneInstance = new ContractA(); function getstateA() public { OneInstance.state = 12; OneInstance.setstate(12); }}The OneInstance.state = 12; line in the getstateA method will raise an error. We need instead to call the setstate() setter to update the state value.
The need for getters (read) and setters (update) in intra-contract interactions demonstrates the importance of the CRUD pattern.
Let’s get ...
Read now
Unlock full access