Skip to content

Instantly share code, notes, and snippets.

@luisnaranjo733
Created January 28, 2022 23:19
Show Gist options
  • Save luisnaranjo733/8cf49d08c4e4d92ad99a82905545f381 to your computer and use it in GitHub Desktop.
Save luisnaranjo733/8cf49d08c4e4d92ad99a82905545f381 to your computer and use it in GitHub Desktop.
Failed transaction - ethernaut secret number
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface ISecretNumber {
function changeOwner(uint8 secretNumber) payable external;
}
// Contract deployed on Rinkeby at 0x0E3E2e9e2054bfC7B169D9c0e640E314d42C6a9a
// Call to changeOwner() fails despite more than enough balance being deposited
contract ChangeOwner {
address owner;
constructor() {
owner = msg.sender;
}
function changeOwner() public {
ISecretNumber(0xE79cfC2c08ff2aEbD647a93BB4629b98E5e5c5d7).changeOwner{ value: 1 ether }(0);
}
function deposit() public payable {
require(msg.value == 1 ether, "Expecting 1 eth deposit");
}
function balance() public view returns (uint) {
return address(this).balance;
}
function dissolve() public {
require(msg.sender == owner);
address payable addr = payable(msg.sender);
selfdestruct(addr);
}
}
@luisnaranjo733
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment