LoginSignup
0
0

More than 5 years have passed since last update.

Level 2. Fallout(The Ethernaut)

Last updated at Posted at 2018-04-25

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

原文はこちら

https://ethernaut.zeppelin.solutions
2. Falloutをクリック

2. Fallout

難易度 2/6
下記のコントラクトのオーナーを自分自身のアドレスに変更することがこのレベルのクリア条件だ。

回答の助けになるヒント
  • Solidity Remix IDEについて

ソースコード

pragma solidity ^0.4.18;

import 'zeppelin-solidity/contracts/ownership/Ownable.sol';

contract Fallout is Ownable {

  mapping (address => uint) allocations;

  /* constructor */
  function Fal1out() public payable {
    owner = msg.sender;
    allocations[owner] = msg.value;
  }

  function allocate() public payable {
    allocations[msg.sender] += msg.value;
  }

  function sendAllocation(address allocator) public {
    require(allocations[allocator] > 0);
    allocator.transfer(allocations[allocator]);
  }

  function collectAllocations() public onlyOwner {
    msg.sender.transfer(this.balance);
  }

  function allocatorBalance(address allocator) public view returns (uint) {
    return allocations[allocator];
  }
}
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