LoginSignup
0
0

More than 5 years have passed since last update.

Level 6. Delegation(The Ethernaut)

Last updated at Posted at 2018-04-25

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

原文はこちら

https://ethernaut.zeppelin.solutions
6. Delegationをクリック

6. Delegation

下記コードのインスタンス(コントラクト)のオーナーを自分自身のアドレスに変更することがこのレベルのクリア

回答の助けになるヒント
  • デリゲートコールにおける低レベル関数がどのように動作するか、デリゲートする為にはどのように使用するか、Solidityのドキュメントを参照せよ。
  • フォールバックメソッドについての理解
  • メソッドid(s)についての理解

ソースコード

pragma solidity ^0.4.18;

contract Delegate {

  address public owner;

  function Delegate(address _owner) public {
    owner = _owner;
  }

  function pwn() public {
    owner = msg.sender;
  }
}

contract Delegation {

  address public owner;
  Delegate delegate;

  function Delegation(address _delegateAddress) public {
    delegate = Delegate(_delegateAddress);
    owner = msg.sender;
  }

  function() public {
    if(delegate.delegatecall(msg.data)) {
      this;
    }
  }
}
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