-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
63 lines (49 loc) · 1.51 KB
/
index.ts
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
54
55
56
57
58
59
60
61
62
63
import { concat, createWalletClient, Hex, http, size, toHex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { kinto } from "viem/chains";
import dotenv from "dotenv";
dotenv.config();
const BUNDLE_BULKER_ADDRESS = "0x8d2D899402ed84b6c0510bB1ad34ee436ADDD20d";
const PER_OP_INFLATOR_ID = 1n;
const NUMBER_OF_USER_OPS = 1n;
const KINTO_INFLATOR_ID = 1n;
const main = async () => {
const pk = process.env.PRIVATE_KEY;
const rpc = process.env.RPC_URL;
if (!pk) {
throw new Error("env var PRIVATE_KEY not set");
}
if (!rpc) {
throw new Error("env var RPC_URL not set");
}
const walletClient = createWalletClient({
chain: kinto,
transport: http(rpc),
account: privateKeyToAccount(pk as Hex),
});
// builtin node.js module
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question("Enter compressed calldata:\n> ", async (compressed: string) => {
compressed = compressed.replace(/\s+/g, "");
const compressedLength = size(compressed as Hex);
const bundleBulkerCalldata = concat([
toHex(PER_OP_INFLATOR_ID, { size: 4 }),
toHex(NUMBER_OF_USER_OPS, { size: 1 }),
toHex(KINTO_INFLATOR_ID, { size: 4 }),
toHex(compressedLength, { size: 2 }),
compressed as Hex,
]);
const hash = await walletClient.sendTransaction({
to: BUNDLE_BULKER_ADDRESS,
data: bundleBulkerCalldata,
gas: 5_000_000n,
});
console.log(`\nhttps://explorer.kinto.xyz/tx/${hash}`);
rl.close();
});
};
main();