首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Solidity keccak256("contract.storage.initialised")

Solidity keccak256("contract.storage.initialised")
EN

Ethereum用户
提问于 2018-01-13 17:01:42
回答 1查看 370关注 0票数 0

嗨,我在寻找可升级/可升级的合同,然后我找到了大卫鲁根代克https://gist.github.com/darcius/6e8fa4faa6d9139f3950b6f1d9e96038的火箭池

代码语言:javascript
复制
/// @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);
    }
    _;
}

有人能帮我理解这两句话吗?

keccak256("contract.storage.initialised")

keccak256("contract.address",msg.sender)

http://solidity.readthedocs.io/en/develop/units-and-global-variables.html#mathematical-and-cryptographic-functions

我知道keccak256(.)或sha3(.)计算(紧密打包的)参数的etuum-Sha-3 (Keccak-256)散列,然后返回(bytes32)。

但是我找不到任何关于".initialised“的参考资料谢谢

EN

回答 1

Ethereum用户

回答已采纳

发布于 2018-01-13 22:12:32

正如@smarx所提到的,在这种情况下,字符串完全是任意的。Keccak256的使用是为了能够以编程方式比较字符串。

如何比较字符串的坚固性?

代码语言:javascript
复制
function compareStrings (string a, string b) view returns (bool){
       return keccak256(a) == keccak256(b);
   }
票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/36138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档