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

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