0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Level 17. Locked. Delegation(The Ethernaut)

Posted at

「The Ethernaut by Zeppelin Level 17. Locked」を翻訳してみました

原文はこちら

https://ethernaut.zeppelin.solutions
17. Lockedをクリック

17. Locked

難易度 6/6
この名前登録コントラクトはロックされており、新しい名前を登録することはできないぞ。
このレベルのクリア条件は、この名前登録コントラクトのロックを解除することだ。

回答の助けになるヒント
  • ストレージの仕組みの理解
  • ローカル変数のデフォルトストレージタイプについての理解
  • ストレージとメモリの違いの理解

ソースコード

pragma solidity ^0.4.23; 

// A Locked Name Registrar
contract Locked {

    bool public unlocked = false;  // registrar locked, no name updates
    
    struct NameRecord { // map hashes to addresses
        bytes32 name; // 
        address mappedAddress;
    }

    mapping(address => NameRecord) public registeredNameRecord; // records who registered names 
    mapping(bytes32 => address) public resolve; // resolves hashes to addresses
    
    function register(bytes32 _name, address _mappedAddress) public {
        // set up the new NameRecord
        NameRecord newRecord;
        newRecord.name = _name;
        newRecord.mappedAddress = _mappedAddress; 

        resolve[_name] = _mappedAddress;
        registeredNameRecord[msg.sender] = newRecord; 

        require(unlocked); // only allow registrations if contract is unlocked
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?