github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/execution/testdata-istanbul/write-protection-005.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity ^0.6.6; 3 4 // NOTE: Deploy this contract first 5 contract B { 6 // NOTE: storage layout must be the same as contract A 7 uint public num; 8 address public sender; 9 uint public value; 10 mapping(uint => uint) private _a; 11 event Done(); 12 13 constructor() public { 14 _a[1] = 1; 15 _a[2] = 2; 16 _a[3] = 3; 17 } 18 19 function setVars(uint _num) public payable { 20 delete _a[1]; 21 delete _a[2]; 22 num = _num; 23 sender = msg.sender; 24 value = msg.value; 25 emit Done(); 26 } 27 } 28 29 contract A { 30 uint public num; 31 address public sender; 32 uint public value; 33 address private c; 34 mapping(uint => uint) private _a; 35 event Success(bool); 36 37 function make() public { 38 c = address(new B()); 39 _a[1] = 1; 40 _a[2] = 2; 41 _a[3] = 3; 42 } 43 44 function setVars(address _contract, uint _num) public returns (uint256) { 45 if (_contract == address(0)) { 46 _contract = c; 47 } 48 delete _a[1]; 49 (bool success, bytes memory _) = _contract.staticcall( 50 abi.encodeWithSignature("setVars(uint256)", _num) 51 ); 52 emit Success(success); 53 54 return 1; 55 } 56 }