generated from emilianobonassi/whitehacks-kit
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Whitehack.s.sol
43 lines (33 loc) · 1.33 KB
/
Whitehack.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "forge-std/Script.sol";
import {Factory} from "../src/Factory.sol";
import {Whitehack} from "../src/Whitehack.sol";
import "../src/interface.sol";
contract WhitehackScript is Script {
function run() public {
vm.startBroadcast();
console.log(msg.sender, "is running the script");
// 0. Prepare the factory to deploy and execute in 1 go the whitehack
// Can be removed if the factory is already deployed
Factory factory = new Factory();
console.log("factory deployed at:", address(factory));
// 1. Prepare the whitehack parameters
bytes memory params = '';
// Advanced
uint256 ethRequired = 0; // you should not need to send eth to the whitehack
// 2. Deploy and execute the whitehack
(address wh, ) = factory.deployAndExec{value: ethRequired}(
ethRequired,
bytes32('whitehack'),
type(Whitehack).creationCode,
abi.encodeWithSignature("go(bytes)", params)
);
console.log("whitehack executed with success");
console.log("saved",
IWFTM(payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2)).balanceOf(Whitehack(payable(wh)).safeBox())/(1e18),
"WETH"
);
vm.stopBroadcast();
}
}