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 13. Gatekeeper One(The Ethernaut)

Last updated at Posted at 2018-05-08

「The Ethernaut by Zeppelin Level 13. Gatekeeper One」を翻訳してみました(CryptoZombiesのように?)

原文はこちら

https://ethernaut.zeppelin.solutions
13. Gatekeeper Oneをクリック

13. Gatekeeper One

難易度 5/6
ゲートキーパー(ここではmodifier修飾子)を通過させ、参加者として登録する(enterメソッドからtrueを返す)ことが
このレベルのクリア条件だ。

回答の助けになるヒント
  • 過去に「4. Telephone」と「5. Token」のレベルから学んだことを思い出せ。
  • Solidityのドキュメント(ここここを参照)で特別な変数「msg.gas」及び推奨エイリアス「gasleft()」について詳しく知ることが出来るぞ。

ソースコード

pragma solidity ^0.4.18;

contract GatekeeperOne {

  address public entrant;

  modifier gateOne() {
    require(msg.sender != tx.origin);
    _;
  }

  modifier gateTwo() {
    require(msg.gas % 8191 == 0);
    _;
  }

  modifier gateThree(bytes8 _gateKey) {
    require(uint32(_gateKey) == uint16(_gateKey));
    require(uint32(_gateKey) != uint64(_gateKey));
    require(uint32(_gateKey) == uint16(tx.origin));
    _;
  }

  function enter(bytes8 _gateKey) public gateOne gateTwo gateThree(_gateKey) returns (bool) {
    entrant = tx.origin;
    return true;
  }
}
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?