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 18. Recovery(The Ethernaut)

Posted at

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

原文はこちら

https://ethernaut.zeppelin.solutions
18. Recoveryをクリック

18. Recovery

難易度 6/6
とあるコントラクト作成者は非常に簡単なトークンファクトリコントラクトを作成した。
(このコントラクトを利用すれば)誰でも簡単に新しいトークンを作成できるぞ。
最初のトークンコントラクトをデプロイした後、コントラクト作成者は0.5個のetherを送り、より多くのトークンを取得した。
しかし、彼らは以来 このコントラクトのアドレスを失ってしまった(泣)。
このレベルのクリア条件は、失われたコントラクトアドレスから0.5ETHを回収(または除去)することだ。

ソースコード

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?