Comments (3)
// 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.
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.
@jamil-wittmann Do you mind posting the exact command you used ? I am having issues recovering.
from rusty-sando.
Related Issues (20)
- What do FrontrunReverted messages mean?
- Is the source code safe for the private key? HOT 1
- Is the source code safe to run?
- panic at unwrap error, Please help!!! HOT 1
- Contracts -> Tests failing
- Cargo Tests result in "Optimal amount in: 0 not sandwichable"
- Compiling ethers-solc cannot find value `SVM_HOME` in crate `svm`
- Contract Deployment
- Always getting [huffsando: REVERT] frontrun HOT 1
- [huffsando: REVERT] frontrun HOT 2
- Recover WETH and ETH JUMPDEST HOT 4
- JUMPDEST locations are incorrect. HOT 2
- metamorphic contracts HOT 3
- Sandwish Contract and Inception Block HOT 2
- Warnings when running cargo run --release --features debug
- huff WETH HOT 2
- Compiler run failed: Error (7858)
- Cannot deploy the contract
- All tests fail.
- Optimize FrontRun [ENHANCEMENT] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rusty-sando.