github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/docs/example/basic-app/simplestorage.sol (about)

     1  pragma solidity >=0.0.0;
     2  
     3  contract simplestorage {
     4      uint public storedData;
     5  
     6      constructor(uint initVal) public {
     7          storedData = initVal;
     8      }
     9  
    10      function set(uint value) public {
    11          storedData = value;
    12      }
    13  
    14      function get() public view returns (uint value) {
    15          return storedData;
    16      }
    17  
    18      // Since transactions are executed atomically we can implement this concurrency primitive in Solidity with the
    19      // desired behaviour
    20      function testAndSet(uint expected, uint newValue) public returns (uint value, bool success) {
    21          if (storedData == expected) {
    22              storedData = newValue;
    23              return (storedData, true);
    24          }
    25          return (storedData, false);
    26      }
    27  }