Giter Site home page Giter Site logo

Comments (3)

praveenbm5 avatar praveenbm5 commented on June 20, 2024 1
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import {IWETH} from "../interfaces/IWETH.sol";

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

contract RecoverWeth is Script {

    IWETH weth = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

    address sandwich;
    address admin;
    address helper;
    
    // serachers
    function setUp() public {
        //change this
        sandwich = 0x0000000000000000000000000000000000000000;
    }
    
    function run() public view {
        console.log(address(sandwich));

        uint256 sandwichBalanceBefore = weth.balanceOf(sandwich);
        console.log("Sandwich Balance: %s", sandwichBalanceBefore);

        //string memory functionName = "recoverWeth"; //0x42 or 66
        bytes memory payload = abi.encodePacked(
            uint8(66),
            sandwichBalanceBefore
        );
        console.log("Payload: ");
        console.logBytes(payload);
    }
}

//save this file to "contract/script" folder and run the following commands from "contract" folder
//forge script ./script/RecoverWeth.s.sol --rpc-url http://127.0.0.1:8545
//get the payload hex from the logs 
//cast send --rpc-url http://127.0.0.1:8545 --private-key <xxxx> <sandwich address> <payload hex>

from rusty-sando.

jamil-wittmann avatar jamil-wittmann commented on June 20, 2024

Solved.

The recover_weth function takes in an input that dictates the amt of weth to withdraw, if this value isn't passed then it will just try withdrawing 0. so in this case to recover 0.005 weth, you first convert 0.005 weth to wei and then convert the wei value to hex. This means that the calldata to recover ur weth will be equal to

0x420000000000000000000000000000000000000000000000000011C37937E08000

from rusty-sando.

0xsepu avatar 0xsepu commented on June 20, 2024

@jamil-wittmann Do you mind posting the exact command you used ? I am having issues recovering.

from rusty-sando.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.