Skip to content

Commit

Permalink
fix: update documentation with. zksync2-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngozi-Txfusion committed Jul 23, 2024
1 parent 1c320c2 commit 2328c3f
Show file tree
Hide file tree
Showing 8 changed files with 1,874 additions and 28 deletions.
73 changes: 71 additions & 2 deletions content/sdk/10.js/00.ethers/04.guides/02.accounts-l1-l2.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,42 @@ If you need background information on how L1<->L2 interactions work on ZKsync, c
`Wallet` and `L1Signer` objects allow you to deposit funds from L1 to L2.

- **More Information**: See the method specification [`Deposit`](/sdk/js/ethers/api/v5/accounts/wallet#deposit).
- **Example**: [Deposit ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/01_deposit.ts).
- **Example**: Deposit ETH and ERC20 token

::collapsible

```sh
import { Provider, types, utils, Wallet } from "zksync-ethers";
import { ethers } from "ethers";

const provider = Provider.getDefaultProvider(types.Network.Sepolia);
const ethProvider = ethers.getDefaultProvider("sepolia");
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider);

async function main() {
console.log(`L2 balance before deposit: ${await wallet.getBalance()}`);
console.log(`L1 balance before deposit: ${await wallet.getBalanceL1()}`);

const tx = await wallet.deposit({
token: utils.ETH_ADDRESS,
to: await wallet.getAddress(),
amount: ethers.parseEther("0.00020"),
refundRecipient: await wallet.getAddress(),
});
const receipt = await tx.wait();
console.log(`Tx: ${receipt.hash}`);

console.log(`L2 balance after deposit: ${await wallet.getBalance()}`);
console.log(`L1 balance after deposit: ${await wallet.getBalanceL1()}`);
}

main()
.then()
.catch((error) => {
console.log(`Error: ${error}`);
});
::
## Request execute
Expand Down Expand Up @@ -44,4 +79,38 @@ If you need background information on how L1<->L2 interactions work on ZKsync, c
`Wallet` and `Signer` objects enable you to withdraw funds from L2 to L1.
- **More Information**: See the method specification [`Withdraw`](/sdk/js/ethers/api/v5/accounts/wallet#withdraw).
- **Example**: [Withdraw ETH and ERC20 token](https://github.com/zksync-sdk/zksync2-examples/blob/main/js/src/04_withdraw.ts).
- **Example**: Withdraw ETH and ERC20 token
::collapsible
```
import { Provider, types, utils, Wallet } from "zksync-ethers";
import { ethers } from "ethers";
const provider = Provider.getDefaultProvider(types.Network.Sepolia);
const ethProvider = ethers.getDefaultProvider("sepolia");
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider);
async function main() {
console.log(`L2 balance before withdraw: ${await wallet.getBalance()}`);
console.log(`L1 balance before withdraw: ${await wallet.getBalanceL1()}`);
const tx = await wallet.withdraw({
token: utils.ETH_ADDRESS,
to: await wallet.getAddress(),
amount: ethers.parseEther("0.00020"),
});
const receipt = await tx.wait();
console.log(`Tx: ${receipt.hash}`);
// The duration for submitting a withdrawal transaction to L1 can last up to 24 hours. For additional information,
// please refer to the documentation: https://era.zksync.io/docs/reference/troubleshooting/withdrawal-delay.html.
// Once the withdrawal transaction is submitted on L1, it needs to be finalized.
// To learn more about how to achieve this, please take a look at the 04_finalize_withdraw.ts script.
}
main()
.then()
.catch((error) => {
console.log(`Error: ${error}`);
});
::
2 changes: 1 addition & 1 deletion content/sdk/20.go/00.introduction/01.why-zksync2-go.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Why zksync2-go
description: Benefits and Advantages of using `zksync2-go`
description: Benefits and Advantages of using zksync2-go
tags: ["zksync", "zksync2-go", "ethereum", "layer-2", "zero-knowledge rollups", "go library"]
---

Expand Down
Loading

0 comments on commit 2328c3f

Please sign in to comment.