-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (47 loc) · 1.75 KB
/
index.js
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
44
45
46
47
48
49
50
51
52
53
const { Contract, utils, Wallet, providers } = require("ethers");
require("dotenv").config();
const { PRIVATE_KEY, RPC_URL, CONTRACT_ADDRESS } = process.env;
if (!PRIVATE_KEY || !RPC_URL || !CONTRACT_ADDRESS) {
console.error("Invalid ENV");
process.exit(1);
}
const provider = new providers.JsonRpcProvider(RPC_URL);
const wallet = new Wallet(PRIVATE_KEY, provider);
const { address } = wallet;
const main = async () => {
console.log("Trying withdrawAll on PoignART!");
console.log({ address });
const balance = await provider.getBalance(address);
console.log({ balance: `${utils.formatEther(balance)} ETH` });
const abi = new utils.Interface(["function withdrawAll() public"]);
const contract = new Contract(CONTRACT_ADDRESS, abi, wallet);
const tx = await contract.withdrawAll({
gasLimit: 100000,
gasPrice: utils.parseUnits("30", "gwei").toString(),
type: 1,
accessList: [
{
address: "0xd9db270c1b5e3bd161e8c8503c55ceabee709552", // gnosis safe implementation address
storageKeys: [
"0x0000000000000000000000000000000000000000000000000000000000000000",
],
},
{
address: "0x10E1439455BD2624878b243819E31CfEE9eb721C", // gnosis safe proxy address of unchain
storageKeys: [
"0x0000000000000000000000000000000000000000000000000000000000000000",
],
},
],
});
console.log({ txHash: tx.hash });
await tx.wait();
console.log("Withdraw Successful!");
};
main()
.then(() => process.exit(0))
.catch((error) => {
console.log("Withdraw Failed!");
console.error(error);
process.exit(1);
});