send-op-tx.ts 483 B

12345678910111213141516171819202122
  1. import { network } from "hardhat";
  2. const { ethers } = await network.connect({
  3. network: "hardhatOp",
  4. chainType: "op",
  5. });
  6. console.log("Sending transaction using the OP chain type");
  7. const [sender] = await ethers.getSigners();
  8. console.log("Sending 1 wei from", sender.address, "to itself");
  9. console.log("Sending L2 transaction");
  10. const tx = await sender.sendTransaction({
  11. to: sender.address,
  12. value: 1n,
  13. });
  14. await tx.wait();
  15. console.log("Transaction sent successfully");