Created
July 25, 2023 11:35
-
-
Save TehilaFavourite/062dd56c571d7c5e009fba26ca70d368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Contract with batch update and separate state updates examples | |
contract StateUpdateExample { | |
uint256 public var1; | |
uint256 public var2; | |
uint256 public var3; | |
// Batch update: Set multiple state variables in a single transaction | |
function batchUpdate(uint256 newValue1, uint256 newValue2, uint256 newValue3) public { | |
var1 = newValue1; | |
var2 = newValue2; | |
var3 = newValue3; | |
} | |
// Separate state updates: Set state variables individually in separate transactions | |
function separateUpdate1(uint256 newValue) public { | |
var1 = newValue; | |
} | |
function separateUpdate2(uint256 newValue) public { | |
var2 = newValue; | |
} | |
function separateUpdate3(uint256 newValue) public { | |
var3 = newValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment