index.mjs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { ethers } from "ethers";
  2. import { Wallet, Provider, utils } from "zksync-web3";
  3. async function orbiter() {
  4. const provider = new ethers.providers.InfuraProvider(
  5. "goerli",
  6. "6e36ce031e304b79af723a0a28789083"
  7. );
  8. const signer = new ethers.Wallet(
  9. "0xd768b0b3f8dedcb465ad680268453391f7da6ec4e1942a13fdfcdea8773aab3e",
  10. provider
  11. );
  12. const tx = await signer.sendTransaction({
  13. from: "0x69b01ecc793b8fb33d5a1199bedfdc47dc55d968",
  14. to: "0x0043d60e87c5dd08C86C3123340705a1556C4719",
  15. value: "6000000000009514",
  16. gasLimit: 21000,
  17. });
  18. console.log("Mining transaction...");
  19. console.log(`https://goerli.etherscan.io/tx/${tx.hash}`);
  20. // Waiting for the transaction to be mined
  21. const receipt = await tx.wait();
  22. // The transaction is now on chain!
  23. console.log(`Mined in block ${receipt.blockNumber}`);
  24. }
  25. async function official() {
  26. const provider = new Provider("https://testnet.era.zksync.dev");
  27. const ethProvider = new ethers.providers.InfuraProvider(
  28. "goerli",
  29. "6e36ce031e304b79af723a0a28789083"
  30. );
  31. const wallet = new Wallet(
  32. "0xd768b0b3f8dedcb465ad680268453391f7da6ec4e1942a13fdfcdea8773aab3e",
  33. provider,
  34. ethProvider
  35. );
  36. // const deposit = await wallet.deposit({
  37. // token: utils.ETH_ADDRESS,
  38. // amount: ethers.utils.parseEther("0.005"),
  39. // });
  40. // console.log("Deposit sent. Awaiting confirmation...");
  41. // // Await processing of the deposit on L1
  42. // const ethereumTxReceipt = await deposit.waitL1Commit();
  43. // console.log("L1 deposit confirmed! Waiting for zkSync...");
  44. // // Await processing the deposit on zkSync
  45. // const depositReceipt = await deposit.wait();
  46. // console.log("zkSync deposit committed.");
  47. console.log("Checking zkSync account balance");
  48. // Retrieving the current (committed) zkSync ETH balance of an account
  49. const committedEthBalance = await wallet.getBalance(utils.ETH_ADDRESS);
  50. console.log("committedEthBalance", ethers.utils.formatEther(committedEthBalance));
  51. // Retrieving the ETH balance of an account in the last finalized zkSync block.
  52. const finalizedEthBalance = await wallet.getBalance(
  53. utils.ETH_ADDRESS,
  54. "finalized"
  55. );
  56. console.log("finalizedEthBalance", ethers.utils.formatEther(finalizedEthBalance));
  57. }
  58. await official();