0

Hi I was searching on upgradeable/upgradable contracts, then I found this Rocket Pool by David Rugendyke https://gist.github.com/darcius/6e8fa4faa6d9139f3950b6f1d9e96038

/// @dev Only allow access from the latest version of a contract in the Rocket Pool network after deployment

modifier onlyLatestRocketNetworkContract() {

    /* The owner is only allowed to set the storage upon deployment 
    to register the initial contracts, afterwards their direct access is disabled
    only allow the owner of the storage contract to access these methods directly to set 
    some initial contract addresses during deployment, 
    after deployment their access is removed to ensure only visible contract methods 
    can write to storage. From then on, only registered contracts within the Rocket Pool network 
    can write to storage.
     */

    if (msg.sender == owner) {
        require(boolStorage[keccak256("contract.storage.initialised")] == false);
    } else {
        // Make sure the access is permitted to only contracts in our Dapp
        require(addressStorage[keccak256("contract.address", msg.sender)] != 0x0);
    }
    _;
}

Could someone help me understand these two lines:
keccak256("contract.storage.initialised")
keccak256("contract.address", msg.sender)

http://solidity.readthedocs.io/en/develop/units-and-global-variables.html#mathematical-and-cryptographic-functions
I know keccak256(...) or sha3(...) computes the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments, then returns (bytes32)

but I could not find any reference regarding to ".initialised" Thank you

  • 1
    Those strings were made up by the personal who wrote this contract. They don't have any special meaning. – smarx Jan 13 '18 at 17:51
1

As @smarx mentioned the strings are entirely arbitrary in this case. The use of Keccak256 is to be able to programmatically compare the strings.

how to compare strings in solidity?

function compareStrings (string a, string b) view returns (bool){
       return keccak256(a) == keccak256(b);
   }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.