forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend-op-tx.ts
More file actions
31 lines (22 loc) · 812 Bytes
/
Copy pathsend-op-tx.ts
File metadata and controls
31 lines (22 loc) · 812 Bytes
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
import { network } from "hardhat";
const { viem } = await network.connect({
network: "hardhatOp",
chainType: "op",
}) as any;
console.log("Sending transaction using the OP chain type");
const publicClient = await viem.getPublicClient();
const [senderClient] = await viem.getWalletClients();
console.log("Sending 1 wei from", senderClient.account.address, "to itself");
const l1Gas = await publicClient.estimateL1Gas({
account: senderClient.account.address,
to: senderClient.account.address,
value: 1n,
});
console.log("Estimated L1 gas:", l1Gas);
console.log("Sending L2 transaction");
const tx = await senderClient.sendTransaction({
to: senderClient.account.address,
value: 1n,
});
await publicClient.waitForTransactionReceipt({ hash: tx });
console.log("Transaction sent successfully");