hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
32 lines (22 loc) • 804 B
text/typescript
import { network } from "hardhat";
const { viem } = await network.create({
network: "hardhatOp",
chainType: "op",
});
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");